TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

[n,l]=inpl()
lsum = n*(n-1)//2 + l*n
if l-1 <= 0 and l-1+n >= 0:
    ans = lsum
elif l-1+n < 0:
    ans = lsum - (l-1+n)
elif l-1 > 0:
    ans = lsum -(l-1)


print(ans)

from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

[n,l]=inpl()
applist = np.arange(1,n+1) + l - 1
applist.sort()

if 0 in applist:
    ans = applist.sum()
elif applist[0] > 0:
    ans = applist[1:].sum()
elif applist[-1] < 0:
    ans = applist[:-1].sum()
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
# -*- coding: utf-8 -*-
N, L = map(int,input().split())

taste = []
for i in range(1,N + 1):
    taste.append(L + i - 1)

SUM = sum(taste)

DIF = abs(SUM - (SUM - taste[0]))
ans = SUM - taste[0]
for i in range(1,N + 1):
    x = SUM - taste[i]
    if abs(SUM - x) < DIF:
        DIF = abs(SUM - x)
        ans = x
print(ans)


# -*- coding: utf-8 -*-
n, l = map(int,input().split())

taste = [l + i - 1 for i in range(1, n + 1)]
taste.sort()
ans = 1000
for i in taste:
    if abs(i) < abs(ans):
        ans = i
print(sum(taste) - ans)


Verdicts: Runtime Error

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
S = list(input())

if (S[0]==S[1])or(S[1]==S[2])or(S[2]==S[3]):
  print('Bad')
else:
  print('Good')


N,L = map(int,input().split())
import math
T = []
for i in range(N):
  T.append(L+i)
cnt = 0
mcnt = sum(T)
k = 1000000
for i in range(0,N):
  if abs(T[i])<k:
    mcnt = sum(T)-T[i]
    cnt = i+1
    k=abs(T[i])
print(mcnt)


Verdicts: Runtime Error

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
N, L = list(map(int, input().split()))

apples = [0] * N

ate_apple = 100
apple_pie = 0

for i in range(N):
  apples[i] = L + i
  apple_pie += apples[i]
  if ate_apple > apples[i]:
    ate_apple = apples[i]

print(apple_pie - (ate_apple * 2))

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

apples = [0] * N

ate_apple = 100
apple_pie = 0

for i in range(N):
  apples[i] = L + i
  apple_pie += apples[i]
  if abs(ate_apple) > abs(apples[i]):
    ate_apple = apples[i]

print(apple_pie - ate_apple)


Verdicts: Wrong Answer

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
i = list(map(int, input().split()))
n = i[0]
l = i[1]
if l >= 0:
    print((n-1)*(2*l+n)/2)
elif l+n-1 <= 0:
    print((n-1)*(2*l+n-2)/2)
else:
    print(n*(2*l+n-1)/2)

i = list(map(int, input().split()))
n = i[0]
l = i[1]
if l >= 0:
    print(round((n-1)*(2*l+n)/2))
elif l+n-1 <= 0:
    print(round((n-1)*(2*l+n-2)/2))
else:
    print(round(n*(2*l+n-1)/2))

Verdicts: Wrong Answer

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
N, L = map(int, input().split())
# N = 30
# L = -50
T_N = (N**2 + (2*L -1)*N)/2
# print(T_N)
array = []
num = 0
for i in range(1,N+1):
    T_i = L + i -1
    T_Ni = T_N - T_i
#     print(T_i)
    T_abs = abs(T_N - T_Ni)
    array.append(T_abs)
    if (min(array) == T_abs):
        num = T_Ni
# print(array)
print(num)

N, L = map(int, input().split())
# N = 30
# L = -50
T_N = (N**2 + (2*L -1)*N)/2
# print(T_N)
array = []
num = 0
for i in range(1,N+1):
    T_i = L + i -1
    T_Ni = T_N - T_i
#     print(T_i)
    T_abs = abs(T_N - T_Ni)
    array.append(T_abs)
    if (min(array) == T_abs):
        num = T_Ni
# print(array)
print(int(num))

Verdicts: Wrong Answer

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
n,l = map(int,input().split())
sum = 0.5 * n * (2 * l + n -1)

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

if max(a) > 0:
        print(max(a))
else:
        print(sum - max(s))

n,l = map(int,input().split())
sum = 0.5 * n * (2 * l + n -1)

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

print(max(a))

n,l = map(int,input().split())
sum = 0.5 * n * (2 * l + n -1)

s = list(l+i-1 for i in range(n+1))
a = list(sum - int(abs(s[j])) for j in range(1,n+1))

if max(a) > 0:
        print(int(max(a)))
elif max(a)<0:
        print(int(sum - max(s)))
else:
        print(int(sum))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):

N,L=map(int,input().split())
taste=list(range(L,L+N))
min_abs=10**5
for i in range(N):
    if abs(sum(taste)-taste[i])<min_abs:
        min_abs=abs(sum(taste)-taste[i])
        rec=taste[i]
        
        
print(sum(taste)-taste[i])

import numpy as np

N,L=map(int,input().split())
taste=list(range(L,L+N))
#print(sum(taste))
min_abs=10**5
for i in range(N):
    if abs(sum(taste)-(sum(taste)-taste[i]))<min_abs:
        min_abs=abs(taste[i])
        rec=taste[i]
        #print(rec)
        
        
print(sum(taste)-rec)

Verdicts: Wrong Answer

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
N = int(input())
L = int(input())

aji = [(i+1)+L-1 for i in range(N)]
min = min(list(map(abs, aji)))
print(sum(aji)-min)

N = int(input())
L = int(input())

aji = [(i+1)+L-1 for i in range(N)]
abs = list(map(abs, aji))
index = abs.index(min(abs))

print(sum(aji)-aji[index])

N = int(input())
L = int(input())

aji = [(i+1)+L-1 for i in range(N)]
min = min(list(map(aji, abs)))
print(sum(aji)-min)

N,L = input().split()

aji = [(i+1)+int(L)-1 for i in range(int(N))]
abs = list(map(abs, aji))
index = abs.index(min(abs))

print(sum(aji)-aji[index])

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The _flavor_ of Apple i is L+i-1, which can be negative.  You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.  You planned to make an apple pie using all of the apples, but being hungry tempts you to eat one of them, which can no longer be used to make the apple pie.  You want to make an apple pie that is as similar as possible to the one that you planned to make. Thus, you will choose the apple to eat so that the flavor of the apple pie made of the remaining N-1 apples will have the smallest possible absolute difference from the flavor of the apple pie made of all the N apples.  Find the flavor of the apple pie made of the remaining N-1 apples when you choose the apple to eat as above.  We can prove that this value is uniquely determined.

Submission attempts (in order):
n, a = map(int, input().split())
L = a
R = a + n - 1
print(L)
print(R)
eat = 0
if R <= 0:
    eat = R
elif L >= 0:
    eat = L

ans = (R+L) * (R-L+1) / 2 - eat
print(int(ans))

n, a = map(int, input().split())
L = a
R = a + n - 1
eat = 0
if R <= 0:
    eat = R
elif L >= 0:
    eat = L

ans = (R+L) * (R-L+1) / 2 - eat
print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
from fractions import gcd
A,B,C,D = map(int,input().split())

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
CD_mod0 = B*math.gcd(C,D)//(C*D) -(A-1)*math.gcd(C,D)//(C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)


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

C_mod0 = B//C - (A-1)//C
D_mod0 = B//D - (A-1)//D
i = D
j = C % D
while j > 0:
    k = j
    j = i % j
    i = k

CD_mod0 = B*i // (C*D) - (A-1)*i // (C*D)
Total = B - A + 1
ans = Total - C_mod0 - D_mod0 + CD_mod0

print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(m, n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x %y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z

def lcm(x, y):
    return (x * y) // gcd(x, y)
a,b,c,d = map(int,input().split())
count = 0
lcm = lcm(c,d)
ans1 = (b // c - a // c + b // d - a // d - b // lcm + a // lcm)
print(b - a - ans1 + 1)


import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a,b,c,d = map(int,input().split())
count = 0
lcm = lcm(c,d)
ans1 = (b // c - a // c + b // d - a // d - b // lcm + a // lcm)
print(b - a - ans1 + 1)


def gcd(m, n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x %y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z
def lcm(x, y):
    return int((x * y) / gcd(x, y))
a,b,c,d = map(int,input().split())
count = 0
if c == 1 or d == 1:
    print(0)
else:
    lcm = lcm(c,d)
    ans1 = (b // c - a-1 // c + b // d - a-1 // d - b // lcm + a-1// lcm)
    print(b - a + 1 - ans1)

def gcd(m, n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x %y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z
def lcm(x, y):
    return int((x * y) / gcd(x, y))
a,b,c,d = map(int,input().split())
count = 0
if c == 1 or d == 1:
    print(0)
else:
    lcm = lcm(c,d)
    ans1 = (b // c - a // c + b // d - a // d - b // lcm + a // lcm)
    print(b - a + 1 - ans1)


def gcd(m, n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x %y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z
def lcm(x, y):
    return int((x * y) / gcd(x, y))
a,b,c,d = map(int,input().split())
count = 0
if c == 1 or d == 1:
    print(0)
else:
    lcm = lcm(c,d)
    ans1 = (b // c - (a-1) // c + b // d - (a-1) // d - b // lcm + (a-1) // lcm)
    print(b - a + 1 - ans1)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import fractions
a,b,c,d=map(int,input().split())
count=0
e=(c*d)//fractions.gcd(c,d)
D=[c,d,e]
f=[]

for i in D:
  f.append((b//i)-(a//i))
print(b-a+1-f[0]-f[1]+f[2])

import math
a,b,c,d=map(int,input().split())
lcm=(c*d)//math.gcd(c,d)
print((b-(b//c+b//d-b//lcm))-(a-1-((a-1)//d+(a-1)//c-(a-1)//lcm)))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b , a%b)	

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

lc = gcd(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+lc_count)

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

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

cd = c * d
cd_count =  (b // cd) - ((a-1) // cd)

lc = lcm(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+cd_count+lc)

import math

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

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

cd = c * d
cd_count =  (b // cd) - ((a-1) // cd)

lc = lcm(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+cd_count+lc)

def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b , a%b)	

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

lc = (c*d) // gcd(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+lc_count)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d=map(int,input().split())
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)

ans=0
ans+=b//c-(a-1)//c
ans+=b//d-(a-1)//d
q=lcm(c,d)
ans+=b//q-(a-1)//q
print(ans)

a,b,c,d=map(int,input().split())
a-=1
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)
aa= b//c-a//c 
bb= b//d-a//d 
cc= b//lcm(c,d)- a//lcm(c,d)
print(b-a-(aa+bb-cc))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):

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

cc = (b // c)- ((a - 1) // c)
dd = (b // d)- ((a - 1) // d)

f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x
# $print(min(f))


cd =(b // (c * d / min(f)))- ((a - 1) // (c * d / min(f)))

print(b - a + 1 - cc - dd + cd)

import math

a, b, c, d = map(int, input().split())
cc = int(b / c) - int(a / c)



dd = int(b / d) - int(a / d)

i = 0
f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x
# Wprint(min(f))


cd = int(b / (c * d )) - int(a / (c * d ))

print(b - a+1 - cc - dd + cd)

import math

a, b, c, d = map(int, input().split())
cc = int(b / c) - int(a / c)



dd = int(b / d) - int(a / d)

i = 0
f = [c]
x = 10000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x
# Wprint(min(f))


cd = int(b / (c * d / min(f))) - int(a / (c * d / min(f)))

print(b - a+1 - cc - dd + cd)


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


f = [c]
x = 1000000
k = [c, d]

while x != 0:
    x = max(k) % min(k)

    if x != 0:
        f.append(x)
    k.sort()
    k[1] = x
#print(min(f))

cc = (b // c)- ((a - 1) // c)
dd = (b // d)- ((a - 1) // d)
cd =(b // (c * d // min(f)))- ((a - 1) // (c * d // min(f)))
#print(cc,"cc")
#print(dd,"dd")
#print(cd,"cd")

print(int(b - a + 1 - cc - dd + cd))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math

temp = input().split(" ")
min = int(temp[0])
max = int(temp[1])
divisor1 = int(temp[2])
divisor2 = int(temp[3])
divisors = [divisor1,divisor2] if divisor1 > divisor2 else [divisor2, divisor1]

def gcd(a,b):
    x = a
    y = b
    mod = b
    while x % y != 0:
        mod = x % y
        x = b
        y = mod
    return mod

gcdDivisors = gcd(divisors[0], divisors[1]);
lcmDivisors = divisor1 * divisor2 / gcdDivisors

divNum1 = max // divisor1 - (min + 1) // divisor1 + 1;
divNum2 = max // divisor2 - (min + 1) // divisor2 + 1;
divNumLcm = math.floor(max / lcmDivisors) - math.ceil(min / lcmDivisors) + 1;

divNumTotal = divNum1 + divNum2 - divNumLcm;
ans = max - min + 1 - divNumTotal

print(int(ans))    


import math

temp = input().split(" ")
min = int(temp[0])
max = int(temp[1])
divisor1 = int(temp[2])
divisor2 = int(temp[3])
divisors = [divisor1,divisor2] if divisor1 > divisor2 else [divisor2, divisor1]

def gcd(a,b):
    x = a
    y = b
    mod = b
    while x % y != 0:
        mod = x % y
        x = b
        y = mod
    return mod

gcdDivisors = gcd(divisors[0], divisors[1]);
lcmDivisors = int(divisor1 * divisor2 / gcdDivisors)

divNum1 = math.floor(max / divisor1) - math.floor((min - 1) / divisor1) + 1;
divNum2 = math.floor(max / divisor2) - math.floor((min - 1) / divisor2) + 1;
divNumLcm = math.floor(max / lcmDivisors) - math.floor((min - 1) / lcmDivisors) + 1;
divNumTotal = divNum1 + divNum2 - divNumLcm;
ans = max - min + 1 - divNumTotal

print(ans)    

import math

temp = input().split(" ")
min = int(temp[0])
max = int(temp[1])
divisor1 = int(temp[2])
divisor2 = int(temp[3])
divisors = [divisor1,divisor2] if divisor1 > divisor2 else [divisor2, divisor1]

def gcd(a,b):
    x = a
    y = b
    mod = b
    while x % y != 0:
        mod = x % y
        x = y
        y = mod
    return mod

gcdDivisors = gcd(divisors[0], divisors[1]);
lcmDivisors = (divisor1 * divisor2) // gcdDivisors

divNum1 = max // divisor1 - (min - 1) // divisor1;
divNum2 = max // divisor2 - (min - 1) // divisor2;
divNumLcm = max // lcmDivisors - (min - 1) // lcmDivisors;

divNumTotal = divNum1 + divNum2 - divNumLcm;
ans = max - min + 1 - divNumTotal

print(int(ans))    


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import numpy as np
import math

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

c = (B  - B%C) / B - ((A-1)  - (A-1)%C)/C
d = (B  - B%D) / B - ((A-1)  - (A-1)%D)/D

CD = (C * D  - (C * D % math.gcd(C, D))) / math.gcd(C, D)
cd = (B  - B%CD) / B - ((A-1)  - (A-1)%CD)/CD

ans = B - (A-1) - (c + d - cd)
ans = int(ans)

print(ans)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

c = B//C - (A-1)//C
d = B//D - (A-1)//D

CD = C * D // gcd(C, D)
cd = B//CD - (A-1)//CD

ans = B - (A-1) - (c + d - cd)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math

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

n_c = B//C - (A-1)//C
n_d = B//D - (A-1)//D
lcm_cd = C*D // math.gcd(C,D)
print(lcm_cd)
n_cd = B//lcm_cd - (A-1)//lcm_cd

print(B-A+1 - (n_c+n_d-n_cd))


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

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

n_c = B//C - (A-1)//C
n_d = B//D - (A-1)//D
lcm_cd = C*D // gcd(C,D)
n_cd = B//lcm_cd - (A-1)//lcm_cd

print(B-A+1 - (n_c+n_d-n_cd))



Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math
A,B,C,D = list(map(int,input().split()))

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

CD = lcm(C,D)

CD1 = (A//CD +1)*CD

kyoutuu = (B-CD1)//CD

C1 = (A//C + 1)*C
Cnum = (B - C1)//C

D1 =(A//D +1)*D
Dnum = (B - D1)//D

print(B-A-Cnum-Dnum+kyoutuu)

import math
l = list(map(int,input().split()))

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

l[0] -= 1
la = l[0] - l[0] // l[2] - l[0] // l[3] + l[0] // lcm(l[2], l[3])
lb = l[1] - l[1] // l[2] - l[1] // l[3] + l[1] // lcm(l[2], l[3])
print(lb - la)

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = map(int, input().split())
def div_num(a, b, c):
    if (a%c)==0:
        return (b//c)-(a//c)+1
    else:
        return (b//c)-(a//c)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
XC = div_num(A, B, C)
XD = div_num(A, B, D)
print("XC==={},  XD==={},  XCD==={}".format(XC,XD,XCD))
print(B-A+1-(XC+XD-XCD))

A, B, C, D = map(int, input().split())
def div_num(a, b, c):
    if (a%c)==0:
        return (b//c)-(a//c)+1
    else:
        return (b//c)-(a//c)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
XC = div_num(A, B, C)
XD = div_num(A, B, D)
XCD = div_num(A,B,int((C*D)/gcd(C,D)))
print(B-A+1-(XC+XD-XCD))

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = map(int, input().split())
num = 0
for i in range(A, B+1):
    if i % C = 0:
        num += 1
    elif i % D = 0:
        num += 1
x_num = B - A + 1 - num
print(x_num)


A, B, C, D = map(int, input().split())
def gcd(a, b):
    if a < b:
        a, b = b, a
    a, b = b, a % b
    if b == 0 :
        return a
    else:
        return gcd(a, b)
cd = C * D //gcd(C, D)
print(B - B // C - B // D + B // cd - A + 1 + (A - 1) // C + (A - 1)// D - (A - 1)// cd)


Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import fractions
A, B, C, D = map(int, input().split())
diff = B - A + 1
count_c = int(B/C) - int((A-1)/C)
count_d = int(B/D) - int((A-1)/D)
cd = int(C*D / fractions.gcd(C,D))
count_cd = int(B/cd) - int((A-1)/cd)
print(diff - count_c - count_d + count_cd)

import fractions
A, B, C, D = map(int, input().split())
diff = B - A + 1
count_c = int(B/C) - int((A-1)/C)
count_d = int(B/D) - int((A-1)/D)
cd = (C*D) // fractions.gcd(C,D)
count_cd = int(B/cd) - int((A-1)/cd)
print(diff - count_c - count_d + count_cd)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
A, B, C, D = map(int, input().split())
diff = B - A + 1
count_c = B//C - (A-1)//C
count_d = B//D - (A-1)//D
cd = lcm(C,D)
count_cd = B//cd - (A-1)//cd
print(diff - count_c - count_d + count_cd)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math

A,B,C,D = map(int, input().split())
a = B//C - A//C
b = B//D - A//D
c = B//math.gcd(C,D) - A//math.gcd(C,D)
print(a+b-c)

import math
 
A,B,C,D = map(int, input().split())
a = B//C - (A-1)//C
b = B//D - (A-1)//D
lcm = C*D//math.gcd(C,D)
c = B//lcm - (A-1)//lcm
print(B-(A-1)-(a+b-c))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
# -*- coding: utf-8 -*-
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b // gcd(a, b)

def anti_division_iter(a, b, r):
    n = b // r
    m = (a-1) // r
    return n - m

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

div_c = anti_division_iter(a, b, c)
div_d = anti_division_iter(a, b, d)
div_cd = anti_division_iter(a, b, lcm(c, d))
print(div_c, div_d, div_cd)

print((b-a+1) - (div_c + div_d - div_cd))


# -*- coding: utf-8 -*-
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b // gcd(a, b)

def anti_division_iter(a, b, r):
    n = b // r
    m = (a-1) // r
    return n - m

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

div_c = anti_division_iter(a, b, c)
div_d = anti_division_iter(a, b, d)
div_cd = anti_division_iter(a, b, lcm(c, d))

print((b-a+1) - (div_c + div_d - div_cd))


Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math
a,b,c,d=map(int,input().split())
ans=b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
e=math.gcd(a,b)
ans+=b//e-(a-1)//e
print(ans)

a,b,c,d=map(int,input(),split())
ans=b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
e=c*d
ans+=b//e-(a-1)//e
print(ans)


a,b,c,d=map(int,input().funcsplit())
ans=b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
e=c*d
ans+=b//e-(a-1)//e
print(ans)

a,b,c,d=int(input().split())
ans=b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
e=c*d
ans+=b//e-(a-1)//e
print(ans)

def gcd(n,m):
    if n<m:
        return gcd(m,n)
    if n%m==0:
        return m
    else:
        return gcd(m,n%m)

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d=map(int, input().split())
for i in range(c,1,-1):
    if c % i == 0 and d % i == 0:
        s = i
        break
s = (c // s) * (d // s) * s
print(b - a + 1 - b//c + a//c - b//d + a//d + b//s - a//s)

a,b,c,d=map(int, input().split())
for i in range(c,1,-1):
    if c % i == 0 and d % i == 0:
        s = i
        break
s = (c // s) * (d // s) * s
print(s)
print(b - a + 1 - b//c + a//c - b//d + a//d + b//s - a//s)


def ABC162C(a,b):#from:https://atcoder.jp/contests/abc162/submissions/11871774
    while b != 0:
        a %= b
        if a == 0:break
        b %= a
    return max(a,b)
    

a,b,c,d=map(int,input().split())
e=c//ABC162C(c,d)*d
print(b-b//c-b//d+b//e-(a-1-(a-1)//c-(a-1)//d+(a-1)//e))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
#3

a,b,c,d = map(int,input().split())
x,y = c,d

while y != 0:
	x,y =y,x%y
x = (c*d)//x

count1 = b - (b//c + b//d -b//x)
count2 = (a - 1) - (a//c + a//d -a//x) 

print(count1 - count2)

a,b,c,d = map(int,input().split())
x,y = c,d

while y != 0:
	x,y =y,x%y
x = (c*d)//x

count1 = b - (b//c + b//d -b//x)
count2 = (a - 1) - ((a-1)//c + (a-1)//d -(a-1)//x) 
print(count1 - count2)

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import fractions
a,b,c,d = map(int, input().split())

p = b//c - a//c
q = b//d - a//d
r = b*fractions.gcd(c,d)//(c*d)
print(b-a+1-p-q+r)

import fractions
a,b,c,d = map(int, input().split())

p = b//c - a//c
q = b//d - a//d
r = b*fractions.gcd(c,d)//(c*d) - a*fractions.gcd(c,d)//(c*d)
print(b-a+1-p-q+r)

import fractions
a,b,c,d = map(int, input().split())
p = (b-a) // c
q = (b-a) // d
r = (b-a) * fractions.gcd(c,d) // (c*d)
print(b-a-p-q+r)

def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)
a,b,c,d = map(int, input().split())
p = b//c + (-a//c) +1
q = b//d + (-a//d) +1
r = b*gcd(c,d)//(c*d) + (-a*gcd(c,d)//(c*d)) +1
print(b-a+1-p-q+r)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d = map(int, input().split())
res = 0
for i in range(a,b+1):
  if i % c == 0 and i % d == 0:
    if a % (c*d) == 0 or b % (c*d) == 0:
      res -= 1
    res -= (b-i)//(c*d)
  elif i % c == 0:
    if a % c == 0 or b % c == 0:
      res += 1
    res += (b-i)//c
  else:
    if a % d == 0 or b % d == 0:
      res += 1
    res += (b-i)//d
    
print(res)    

def extgcd(a,b,list=[1,0,0,1]):
    x1,y1,x2,y2 = list
    if b != 0:
        f1 = x2;f2 = y2
        x2 = x1 - int(a/b)*x2
        y2 = y1 - int(a/b)*y2
        list = [f1,f2,x2,y2]
        x,y,a = extgcd(b,a%b,list)
    else:
        x,y = list[:2]
        return x,y,a

    return x,y,a

a,b,c,d = map(int, input().split())
minus = (c*d)//(extgcd(c,d)[2])
ans = b//c + b//d - b//minus
res = (a-1)//c + (a-1)//d - (a-1)//minus
ans = ans-res
t = b-a+1
print(t-ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def gcd(a,b):
    while b != 0:
        temp = b
        b = a%b
        a = temp
    return a
A,B,C,D = map(int,input().split())
if C >=D ;
    lc = int(C*D/gcd(C,D))
else: lc = int(C*D/gcd(D,C))
A = A-1
A_n = A - (A//C + A//D - A//lc)
B_n = B - (B//C + B//D - B//lc)
print(int(B_n-A_n))

def gcd(a,b):
    while b != 0:
        temp = b
        b = a%b
        a = temp
    return a
A,B,C,D = map(int,input().split())
if C >=D:
    lc = int(C*D/gcd(C,D))
else: lc = int(C*D/gcd(D,C))
A = A-1
A_n = A - (A//C + A//D - A//lc)
B_n = B - (B//C + B//D - B//lc)
print(int(B_n-A_n))

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
#!/usr/bin/env python
# coding: utf-8

# In[129]:


import fractions


# In[124]:


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


# In[137]:


lcm = int(C*D / fractions.gcd(C, D))


# In[138]:


c_part_a = int((A - 1) / C)
d_part_a = int((A - 1) / D)
cd_part_a = int((A - 1) / lcm)

c_part_b = int(B / C)
d_part_b = int(B / D)
cd_part_b = int(B / lcm)


# In[143]:


ans1 = (A - 1) - (c_part_a + d_part_a - cd_part_a)
ans2 = B - (c_part_b + d_part_b - cd_part_b)


# In[144]:


print(ans2 - ans1)


# In[ ]:






#!/usr/bin/env python
# coding: utf-8

# In[129]:


import fractions


# In[124]:


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


# In[137]:


lcm = int(C*D / fractions.gcd(C, D))


# In[138]:


c_part_a = int(A / C)
d_part_a = int(A / D)
cd_part_a = int(A / lcm)

c_part_b = int(B / C)
d_part_b = int(B / D)
cd_part_b = int(B / lcm)


# In[139]:


ans1 = (A-1) - (c_part_a + d_part_a - cd_part_a)
ans2 = B - (c_part_b + d_part_b - cd_part_b)


# In[140]:


print(ans2 - ans1)


# In[ ]:






#!/usr/bin/env python
# coding: utf-8

# In[123]:


import fractions


# In[124]:


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


# In[125]:


lcm = int(C*D / fractions.gcd(C, D))


# In[126]:


c_part_a = int((A - 1) / C)
d_part_a = int((A - 1) / D)
cd_part_a = int((A - 1) / lcm)

c_part_b = int(B / C)
d_part_b = int(B / D)
cd_part_b = int(B / lcm)


# In[127]:


ans1 = (A-1) - (c_part_a + d_part_a - cd_part_a)
ans2 = B - (c_part_b + d_part_b - cd_part_b)


# In[128]:


print(ans2 - ans1)


# In[ ]:






#!/usr/bin/env python
# coding: utf-8

# In[8]:


import math


# In[5]:


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


# In[14]:


ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
a_both = (A-1)//(C*D//math.gcd(C,D))
b_both = B//(C*D//math.gcd(C,D))
print((B-A+1) - (bc-ac) - (bd-ad) + (b_both-a_both))


# In[ ]:






Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a, b, c, d = map(int, input().split())
l = lcm(c, d)
bad = (b // c) - ((a-1) // c) + (b // d) - ((a-1) // d) - (b // l) + ((a-1) // l)
ans = b - a + 1 - bad
print(ans)

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = map(int, input().split())
l = lcm(c, d)
bad = (b // c) - ((a-1) // c) + (b // d) - ((a-1) // d) - (b // l) + ((a-1) // l)
ans = b - a + 1 - bad
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math
a,b,c,d = map(int, input().split())
 

first = [c,d%c]
first.sort()
if d%c==0:
  cd = c
elif first[0]==1:
  cd = 1
else:
  while first[0]>=2:
    first[1] = first[1]%first[0]
    first.sort()
    if first[0]==0:
      cd = first[1]
    elif first[0]==1:
      cd = 1
lcm = c*d/cd
      
zen = b-a+1
c_num = (b//c)-math.ceil(a/c)+1
d_num = (b//d)-math.ceil(a/d)+1
lcm_num = (b//lcm)-math.ceil(a/lcm)+1
ans = zen-c_num-d_num+lcm_num
print(ans)

import math
a,b,c,d = map(int, input().split())


first = [c,d%c]
first.sort()
if d%c==0:
  cd = c
elif first[0]==1:
  cd = 1
else:
  while first[0]>=2:
    first[1] = first[1]%first[0]
    first.sort()
    if first[0]==0:
      cd = first[1]
    elif first[0]==1:
      cd = 1
      
zen = b-a+1
c_num = b//c -math.ceil(a/c)+1
d_num = b//d -math.ceil(a/d)+1
lcm_num = b//(c*d/cd) - math.ceil(a/(c*d/cd))+1
ans = zen - c_num - d_num + lcm_num
print(ans)

import math
a,b,c,d = map(int, input().split())
 

first = [c,d%c]
first.sort()
if d%c==0:
  cd = c
elif first[0]==1:
  cd = 1
else:
  while first[0]>=2:
    first[1] = first[1]%first[0]
    first.sort()
    if first[0]==0:
      cd = first[1]
    elif first[0]==1:
      cd = 1
lcm = c*d//cd
 

zen = b-a+1
if a%c==0:
  c_num = b//c - a//c + 1
else:
  c_num = b//c - a//c
  
if a%d==0:
  d_num = b//d - a//d + 1
else:
  d_num = b//d - a//d
  
if a%lcm==0:
  lcm_num = b//lcm - a//lcm + 1
else:
  lcm_num = b//lcm - a//lcm

ans = zen - c_num - d_num + lcm_num
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math

def ceil(x, y):
    res = int(math.ceil(x/y))
    return res if x//y!=0 else 0

A,B,C,D = list(map(int, input().split()))
low = ceil(A,C) + ceil(A,D) + ceil(A, C*D)
high = B//C + B//D + B//(C*D)
print(B - A - (high - low))

def calc_gcd(x,y):
    amari = max(x,y)%min(x,y)
    if amari == 0:
        return min(x,y)
    return calc_gcd(min(x,y), amari)
def calc_scm(x,y,gcd):
    return x*y//gcd

A,B,C,D = list(map(int, input().split()))
scm = calc_scm(C,D,calc_gcd(C,D))
low = (A-1)//C + (A-1)//D - (A-1)//scm
high = B//C + B//D - B//scm
print(B - A + 1 - (high - low))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
import math
a,b,c,d = map(int, input().split())
lcm = (c*d)//math.gcd(c,d)
print(lcm)
sum = b-a+1
x = (b//c) - ((a-1)//c)
y = (b//d) - ((a-1)//d)
z = (b//lcm) - ((a-1)//lcm)
n_i = x+y-z
print(int(sum-n_i))

from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from math import gcd

a,b,c,d=nii()

a_c=(a-1)//c
b_c=b//c

a_d=(a-1)//d
b_d=b//d

lcm=(c*d)//gcd(c,d)
a_lcm=(a-1)//lcm
b_lcm=b//lcm

print((b-a+1)-(b_c-a_c)-(b_d-a_d)+(b_lcm-a_lcm))

Verdicts: Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
def cnt(A, B, X):
    A1 = -(-A // X)
    B1 = B // X
    return B1 - A1 + 1

A, B, C, D = map(int,input().split())
print((B - A + 1) - cnt(A, B, C) - cnt(A, B, D) - cnt(A, B, C * D))

def cnt(A, B, X):
    A1 = -(-A // X)
    B1 = B // X
    return B1 - A1 + 1

def gcd(A, B):
    mul = A * B
    if A < B:
        A, B = B, A
    while B:
        A, B = B, A % B
    return mul // A 

A, B, C, D = map(int,input().split())
print((B - A + 1) - cnt(A, B, C) - cnt(A, B, D) + cnt(A, B, gcd(C, D)))

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

div1 = b//c - a//c

div2 = b//d - a//d

e = lcm(c,d)
div3 = b//e - a//e
ans = b-a+1 - div1 - div2 + div3
print(ans)



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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

div1 = b//c - a//c

div2 = b//d - a//d

e = lcm(c,d)
div3 = b//e - a//e

if a%c==0:
    div1 += 1
if a%d==0:
    div2 += 1
if a%e==0:
    div3 += 1

ans = b-a+1 - div1 - div2 + div3
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = map(int, input().split())
ans = set()
for i in range(A//C + 1, B //C + 1):
    ans.add(i*C)

for i in range(A//D + 1, B //D + 1):
    ans.add(i*D)
    


print(B - A + 1 - len(ans))

A, B, C, D = map(int, input().split())
ans = set(list(range(A, B+1)))


for i in range(A//C + 1, B //C + 1):
    if i*C in ans:
        ans.remove(i*C)

for i in range(A//D + 1, B //D + 1):
    if i*D in ans:
        ans.remove(i*D)
    


print(len(ans))

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

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


A, B, C, D = map(int, input().split())
ans = set()
if A%C == 0:
    c = (B//C) - (A//C) + 1
else:
    c = (B//C) - (A//C)

if A%D == 0:
    d = (B//D) - (A//D) + 1
else:
    d = (B//D) - (A//D)

CD = lcm(C, D)

if A%CD == 0:
    cd = (B//CD) - (A//CD) + 1
else:
    cd = (B//CD) - (A//CD)

print(B - A + 1 - (c+d-cd))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    print(y)
  else:
    gcd(x%y,y)
    
r=gcd(c,d)    
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(b-a+1-s-t+u)

a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x%y,y)
    
r=(c*d)/gcd(c,d)    
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(int(b-a+1-s-t+u))


a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(x%y,y)
    
r=gcd(c,d)    
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(b-a+1-s-t+u)


a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)
    
r=gcd(c,d)    
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(b-a+1-s-t+u)


a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)
    
r=int((c*d)/gcd(c,d)) 
s=(b//c)-((a-1)//c)
t=(b//d)-((a-1)//d)
u=(b//r)-((a-1)//r)

print(int(b-a+1-s-t+u))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
A, B, C, D = map(int, input().split())
min = min(C, D)
max = max(C, D)
c=0
d=0
e=0

def gcd(max, min):
  while min:
    max, min = min, max%min
  return max
lcm = max*min//gcd(max,min)
if A>=C:
  c = B//C-(-(-A//C))+1
if A>=D:
  d = B//D-(-(-A//D))+1
if B>=lcm:
  e = B//lcm-(-(-A//lcm))+1
print(c)
print(d)
print(e)

print(B-A+1-(c+d-e))


A, B, C, D = map(int, input().split())
min = min(C, D)
max = max(C, D)
c=0
d=0
e=0

def gcd(max, min):
  while min:
    max, min = min, max%min
  return max
lcm = max*min//gcd(max,min)
c = B//C-A//C
d = B//D-A//D
if lcm <= A:
  e = B//lcm-(-(-A//lcm))
else:
  e = B//lcm
print(c)
print(d)
print(e)

print(B-A+1-(c+d-e))


A, B, C, D = map(int, input().split())
min = min(C, D)
max = max(C, D)
 
def gcd(max, min):
  while min:
    max, min = min, max%min
  return max
lcm = max*min//gcd(max,min)


c = B//C-(-(-A//C))+1

d = B//D-(-(-A//D))+1

e = B//lcm-(-(-A//lcm))+1

print(B-A+1-(c+d-e))

Verdicts: Wrong Answer

Wrong Answer

Accepted