Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03612 (python)

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

i=0
ans=0
while i<n-1:
    if p[i] == i+1 and p[i+1] == i+2:
        p[i],p[i+1] = p[i+1],p[i]
        ans+=1
    elif p[i] == i+1 and p[i+1] != i+2:
        p[i],p[i+1] = p[i+1],p[i]
        ans+=1
    i+=1
if p[n-1] == n and p[n-2]!=n-1:
    ans+=1
print(ans)

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

i=0
ans=0
while i<n-1:                                                                                     if p[i] == i+1 and p[i+1] == i+2:
        p[i],p[i+1] = p[i+1],p[i]
        ans+=1
    elif p[i] == i+1 and p[i+1] != i+2:
        p[i],p[i+1] = p[i+1],p[i]
        ans+=1
    i+=1
if p[n-1] == n and p[n-2]!=n-1:
    ans+=1
print(ans)
Problem p03624 (python)

Fixed submission:
s=input()

sets=set(s)

for i in range(97,123):
  if not chr(i) in sets:
    print(chr(i))
    exit()
print("None")

Buggy submission (verdict: Runtime Error):
s=input()

sets=set(s)

for i in range(97,123):
  if not ord(i) in sets:
    print(ord(i))
    exit()
print("None")
Problem p03633 (python)

Fixed submission:
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))

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

result=1
for num in S:
    result = lcm(result,num)
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))

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

result=1
for num in S:
    result = lcm(result,num)
print(result)
Problem p03665 (python)

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

even_num=0
odd_num=0

for a in A:
    if a%2==0:
        even_num+=1
    else:
        odd_num+=1

ev_case = 2**even_num


from math import factorial

res=0
for i in range(P,odd_num+1,2):                                                                   res += factorial(odd_num) / factorial(i) / factorial(odd_num - i)

print(int(ev_case*res))

Buggy submission (verdict: Runtime Error):
N,P = map(int, input().split())
A = list(map(int, input().split()))

even_num=0
odd_num=0

for a in A:
    if a%2==0:
        even_num+=1
    else:
        odd_num+=1

ev_case = 2**even_num

from scipy.special import comb

res=0
for i in range(P,odd_num+1,2):
    res += comb(odd_num, i, exact=True)

print(ev_case*res)
Problem p03679 (python)

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

if b<=a:
  print("delicious")
elif a+x>=b:
  print("safe")
else:
  print("dangerous")

Buggy submission (verdict: Runtime Error):
x,a,b=map(int, input().split())

if b<=a:
  print("delicious")
elif a+x>b:
  print("dangerous")
else:
  print("safe"
Problem p03698 (python)

Fixed submission:
s=input()
import collections
c = collections.Counter(s)

for i in c.values():
  if i!=1:
    print("no")
    exit()
print("yes")

Buggy submission (verdict: Runtime Error):
s=input()
import collections
c = collections.Counter(l)

for i in c.values():
  if i!=1:
    print("no")
    exit()
print("yes")
Problem p03711 (python)

Fixed submission:
x,y = map(int, input().split())
if x==2 or y==2:
  print("No")
  exit()

if x==4 or x==6 or x==9 or x==11:
  if y==4 or y==6 or y==9 or y==11:
    print("Yes")
  else:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
if x==2 or y==2:
  print("No")
  exit()

if x==4 or x==6 or x==9 or x==11:
  if y==4 or y==6 or y==9 or y~=11:
    print("Yes")
  else:
    print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
if x==2 or y==2:
  print("No")
  exit()

if x==4 or x==6 or x==9 or x==11:
  if y==4 or y==6 or y==9 or y~=11:
    print("Yes")
  else:
    print("No")
else:
	print("No")
Problem p03720 (python)

Fixed submission:
n,m = map(int, input().split())
ans=[0]*n
for i in range(m):
  a,b = list(map(int,input().split()))
  ans[a-1]+=1
  ans[b-1]+=1
for i in range(n):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
ans=[0]*n
for i in range(n):
  a,b = list(map(int,input().split()))
  ans[a-1]+=1
  ans[b-1]+=1
for i in range(n):
  print(ans[i])
Problem p03722 (python)

Fixed submission:
n,m = map(int, input().split())
link = []
for i in range(m):
    tmp = list(map(int,input().split()))
    link.append([tmp[0]-1,tmp[1]-1,-tmp[2]])

def bell(edges, start,num_v):
    cost = [float('inf')] * num_v
    cost[start] = 0
    for _ in range(num_v):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return -1,cost
    return 1,cost

ans1,d = bell(link,0,n)

if ans1 == -1:
    inf_flag = [False]*n
    for i in range(n):
        for f, t, c in link:
            if d[f] == float("inf"): continue
            if inf_flag[f] == True:
                inf_flag[t] = True
            if d[t] > d[f] + c:
                d[t] = d[f] + c
                inf_flag[t] = True
    print("inf" if inf_flag[n-1] else -d[n-1])
else:
    print(-d[-1])

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
link = []
for i in range(m):
    tmp = list(map(int,input().split()))
    link.append([tmp[0]-1,tmp[1]-1,-tmp[2]])

def bell(edges, start,num_v):
    cost = [float('inf')] * num_v
    cost[start] = 0
    for _ in range(num_v):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return -1,cost
    return 1,cost

ans1,d = bell(link,0,n)

if ans1 == -1:
    inf_flag = [False]*n
    for i in range(n):
        for f, t, c in link:
            if d[f] == float("inf"): continue
            if inf_flag[f] == True:
                inf_flag[t] = True
            if d[t] > d[f] + c:
                d[t] = d[f] + c
                inf_flag[t] = True
    print("inf" if inf_flag[n-1] else -d[n-1])
else:
    print(-ans2[-1])

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
link = []
for i in range(m):
    tmp = list(map(int,input().split()))
    link.append([tmp[0]-1,tmp[1]-1,-tmp[2]])

def bell(edges, start,num_v):
    cost = [float('inf')] * num_v
    cost[start] = 0
    for _ in range(num_v):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return -1,cost
    return 1,cost

ans1,ans2 = bell(link,0,n)

if ans1 == -1:
    inf_flag = [False]*N
    for i in range(N):
        for f, t, c in v:
            if d[f] == inf: continue
            if inf_flag[f] == True:
                inf_flag[t] = True
            if d[t] > d[f] + c:
                d[t] = d[f] + c
                inf_flag[t] = True
    print("inf" if inf_flag[N-1] else -d[N-1])
else:
    print(-ans2[-1])
Problem p03796 (python)

Fixed submission:
n= int(input())
def fact_m(n, modulus=10**9+7):
    ans=1
    if n <= modulus//2:
        for i in range(1,n+1):
            ans = (ans * i) % modulus   
    else:
        for i in range(1,modulus-n):
            ans = (ans * i) % modulus
        ans = modinv(ans, modulus)

        if n % 2 == 0:
            ans = -1*ans + modulus
    return ans % modulus
print(fact_m(n))

Buggy submission (verdict: Runtime Error):
n= int(input())
def fact_m(n, modulus=10**9+7):
    ans=1
    if n <= modulus//2:
        for i in range(1,n+1):
            ans = (ans * i) % modulus   
    else:
        for i in range(1,modulus-n):
            ans = (ans * i) % modulus
        ans = modinv(ans, modulus)

        if n % 2 == 0:
            ans = -1*ans + modulus
    return ans % modulus
print(fact_m(m))
Problem p03910 (python)

Fixed submission:
n = int(input())
import math

def getk(num):
    return int((1+math.sqrt(8*num-7))/2)

while(True):
    k = getk(n)
    print(k)
    n-=k
    if k == 1 or n<=0:
        break

Buggy submission (verdict: Runtime Error):
n = int(input())
import math

def getk(n):
    return int((1+math.sqrt(8*n-7))/2)

while(True):
    k = getk(n)
    print(k,end="")
    print(" ",end="")
    if k ==1:
        break
    n-=k
Problem p04003 (python)

Fixed submission:
import sys
input=sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heappop,heappushpop,heapify
n,m = map(int, input().split())
link = defaultdict(list)
chg=10**8
for _ in range(m):
    p,q,c=map(int, input().split())
    link[p].append([p+chg*c,1])
    link[p+chg*c].append([p,1])

    link[q+chg*c].append([p+chg*c,0])
    link[p+chg*c].append([q+chg*c,0])

    link[q+chg*c].append([q,1])
    link[q].append([q+chg*c,1])

def dks(g,start):
    INF=float('inf')
    visited = set()
    hq = []
    heappush(hq, (0,start))
    while hq:
        shortest, i = heappop(hq)
        if i in visited:
            continue
        visited.add(i)
        for j, t in g[i]:
            if j in visited:
                continue
            if j==n:
                return (shortest+t)//2
            heappush(hq, (shortest + t, j))
    return -1
ans=dks(link,1)
print(ans)

Buggy submission (verdict: Runtime Error):
input=sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heappop,heappushpop,heapify
n,m = map(int, input().split())
link = defaultdict(list)
chg=10**8
for _ in range(m):
    p,q,c=map(int, input().split())
    link[p].append([p+chg*c,1])
    link[p+chg*c].append([p,1])

    link[q+chg*c].append([p+chg*c,0])
    link[p+chg*c].append([q+chg*c,0])

    link[q+chg*c].append([q,1])
    link[q].append([q+chg*c,1])

def dks(g,start):
    INF=float('inf')
    visited = set()
    hq = []
    heappush(hq, (0,start))
    while hq:
        shortest, i = heappop(hq)
        if i in visited:
            continue
        visited.add(i)
        for j, t in g[i]:
            if j in visited:
                continue
            if j==n:
                return (shortest+t)//2
            heappush(hq, (shortest + t, j))
    return -1
ans=dks(link,1)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,m = map(int, input().split())
link = defaultdict(list)
for _ in range(m):
    p,q,c=map(int, input().split())
    p-=1
    q-=1
    c-=1
    link[(p,-1)].append([(p,c),1])
    link[(p,c)].append([(p,-1),1])
    link[(p,c)].append([(q,c),0])
    link[(q,c)].append([(p,c),0])
    link[(q,-1)].append([(q,c),1])
    link[(q,c)].append([(q,-1),1])
Problem p04019 (python)

Fixed submission:
s=input()
import collections
c = collections.Counter(s)

if (c["N"]!=0 and c["S"]==0) or (c["N"]==0 and c["S"]!=0) or (c["W"]!=0 and c["E"]==0) or (c["W"]==0 and c["E"]!=0):
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
import collections
c = collections.Counter(l)

if (c["N"]!=0 and c["S"]==0) or (c["N"]==0 and c["S"]!=0) or (c["W"]!=0 and c["E"]==0) or (c["W"]==0 and c["E"]!=0):
  print("Yes")
else:
  print("No")
Problem p02536 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  uf.union(a,b)
print(uf.group_count()-1)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  a,b=map(int,input().split())
  uf.union(a,b)
print(uf.group_count()-1)
Problem p02641 (python)

Fixed submission:
import sys
X,n=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]

nai=[]
if n==0:
  print(X)
  sys.exit()
else:
  if X not in p:
    print(X)
    sys.exit()
  else:
    for i in range(-200,301):
      if i not in p:
        nai.append(i)
    nai.append(X)
    nai.sort()

    ind=nai.index(X)
    
    if abs(nai[ind-1]-X)<=abs(nai[ind+1]-X):
      print(nai[ind-1])
      sys.exit()
    else:
      print(nai[ind+1])
      sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
X,n=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]

nai=[]
if n==0:
  print(X)
  sys.exit()
else:
  if X not in p:
    print(X)
    sys.exit()
  else:
    for i in range(-100,101):
      if i not in p:
        nai.append(i)
    nai.append(X)
    nai.sort()

    for i in range(len(nai)):
      if nai[i]==X:
        if abs(nai[i-1]-X)<=abs(nai[i+1]-X):
          print(nai[i-1])
        else:
          print(nai[i+1])
          sys.exit()
Problem p02683 (python)

Fixed submission:
N,M,X=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(N):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

A=[0 for i in range(M+2)]
flag=1
ans=10**10
cnt=0
for i in range(2**N):
  flag=1
  cost=0
  for j in range(N):
    if i>>j & 1:
      now=l[N-j-1]
      cost+=now[0]
      for s in range(M):
        A[s]+=now[s+1]
  for t in range(M):
    if X<=A[t]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)
    cnt+=1

  A=[0 for v in range(M+2)]

if cnt==0:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,M,X=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(N):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

A=[0 for i in range(M+2)]
flag=1
ans=10**10
cnt=0
for i in range(2**N):
  flag=1
  cost=0
  for j in range(N):
    if i>>j & 1:
      now=l[N-j-1]
      cost+=now[0]
      for s in range(M):
        A[s]+=now[s+1]
  for t in range(M):
    if X<=A[t]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)
    cnt+=1

  A=[0 for v in range(N)]

if cnt==0:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,M,X=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(N):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

A=[0 for i in range(M+2)]
flag=1
ans=float('inf')
cnt=0
for i in range(2**N):
  flag=1
  cost=0
  for j in range(N):
    if i>>j & 1:
      now=l[N-j-1]
      cost+=now[0]
      for s in range(M):
        A[s]+=now[s+1]
  for t in range(M):
    if X<=A[t]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)
    cnt+=1

  A=[0 for v in range(N)]

if cnt==0:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,M,X=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(N):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

A=[0]*(M+2)
flag=1
ans=float('inf')
cnt=0
for i in range(2**N):
  flag=1
  cost=0
  for j in range(N):
    if i>>j & 1:
      now=l[N-j-1]
      cost+=now[0]
      for s in range(M):
        A[s]+=now[s+1]
  for t in range(M):
    if X<=A[t]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)
    cnt+=1

  A=[0]*N

if cnt==0:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
N,M,X=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(N):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

cost=float('inf')
A=[0]*(M+2)
flag=1
ans=float('inf')
for i in range(2**N):
  flag=1
  cost=0
  for j in range(N):
    if i>>j & 1:
      now=l[N-j-1]
      cost+=now[0]
      for s in range(M):
        A[s]+=now[s+1]
  for t in range(M):
    if X<=A[t]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)

  A=[0]*N
if ans==float('inf'):
  print(-1)
else:
  print(ans)
Problem p02684 (python)

Fixed submission:
N,K=[int(x) for x in input().rstrip().split()]
A=[int(x) for x in input().rstrip().split()]

stack=[]
done=[0 for i in range(2*(10**5))]
done[0]=0
now=0
dou=[]

while(done[now]<2):
  
  if done[now]==0:
    stack.append(now)
  else:
    dou.append(now)
  done[now]+=1
  now=A[now]-1

if K<len(stack):
  print(stack[K]+1)
else:
  print(dou[(K-len(stack)-len(dou))%len(dou)]+1)

Buggy submission (verdict: Runtime Error):
N,K=[int(x) for x in input().rstrip().split()]
A=[int(x) for x in input().rstrip().split()]
stack=[]
done=[0 for i in range(N)]
done[0]=0
now=1
amari=[]
cnt=0
for i in range(10**5):
  done[now-1]+=1
  if done[now-1]==2:
    cnt+=1

  if done[now-1]==3:
    break
  
  stack.append(now)
  now=A[now-1]

ans=K%cnt
print(stack[ans])
Problem p02713 (python)

Fixed submission:
from math import gcd
K=int(input())

result=[]
count=0
cnt=0
# def gcd(a,b):
#   while b!=0:
#     a,b=b,a%b
#   return a

 
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      cnt+=gcd(gcd(i,j),k)


print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
ans=S.count("R")*S.count("G")*S.count("B")
 
for i in range(N):
  for j in range(i+1,N):
    k=j+(j-i)
    if N-1<k:
      break
 
    if S[j]!=S[i] and S[j]!=S[k] and S[k]!=S[i]:
        ans-=1
        
print(ans)
Problem p02765 (python)

Fixed submission:
N,R = [int(x) for x in input().rstrip().split()]
if N<10:
    print(R+100*(10-N))
else:
    print(R)

Buggy submission (verdict: Runtime Error):
import math
n,a,b = [int(x) for x in input().rstrip().split()]
n1=1
st=1
ans=0
for i in range(1,n+1):
    n1=n1*(n-i+1)
    st=st*i
    if i==a or i==b:
        continue
    else:
        ans+=(n1//st)%(10**9+7)
 
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,a,b = [int(x) for x in input().rstrip().split()]
l=[]
n1=1
st=1
ans=0
for i in range(1,n+1):
    n1=n1*(n-i+1)
    st=st*i
    ans1 = (n1//st)
    if i==a or i==b:
        l.append(n1//st)
        continue
    else:
        if n<(i/2):
            ans+=l[n-i]
        else:
            ans+=ans1
            l.append(ans1)

print(ans%(10**9+7))
Problem p02772 (python)

Fixed submission:
n=int(input())
l=[int(x) for x in input().rstrip().split() if int(x)%2==0]

cnt = 0
for i in l:
    if i%3 == 0 or i%5==0:
        cnt += 1
    else:
        break

if cnt == len(l):
    print("APPROVED")
else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
N=int(input())
l=[int(x) for x in input().rstrip().split()]

for i in l:
  if i%2==0:
    if (i%5==0 or i%3==0):
      flag=1
    else:
      flag=0
      break
if flag==1:
  print("APPROVED")
else:
  print("DENIED")
Problem p02983 (python)

Fixed submission:
import sys
L,R=[int(x) for x in input().strip().split()]

tmp=10**9+1
ans=10**9+1

for i in range(L,R,1):
  for j in range(L+1,R+1,1):
    if i<j:
      ans=min((i*j)%2019,ans)
  
      if ans==0:
        print(0)
        sys.exit()
print(ans)


# 332701087 1753412895

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
import sys
mod=2019
ans=float('inf')

for i in range(l,r+1):
  for j in range(j+1,r+1):
    ans=min((i*j)%mod,ans)
    if ans==0:
      print(0)
      sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
import sys
mod=2019
ans=float('inf')

for i in range(l,r):
  for j in range(j+1,r+1):
    ans=min((i%mod)*(j%mod),ans)
    if ans==0:
      print(0)
      sys.exit()
print(ans)
Problem p02995 (python)

Fixed submission:
import fractions
from functools import reduce

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0

import math

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

    
baisuu=lcm(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu

u_B=B-B//C-B//D+B//baisuu

print(u_B-u_A)

Buggy submission (verdict: Runtime Error):


A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0

import math

def lcm(x, y):
  if x!=0 and y!=0:
    return (x * y) // math.gcd(x, y)
  else:
    return 0

    
baisuu=lcm(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu

u_B=B-B//C-B//D+B//baisuu

print(u_B-u_A)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0


def lcm(x, y):
  if x!=0 and y!=0:
    return (x * y) // math.gcd(x, y)
  else:
    return 0

    
baisuu=lcm(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu

u_B=B-B//C-B//D+B//baisuu

print(u_B-u_A)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0


def lcm(x, y):
  if x!=0 and y!=0:
    return (x * y) // math.gcd(x, y)
  else:
    return 0

    
baisuu=lcm(C,D)
yakusuu=math.gcd(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu

u_B=B-B//C-B//D+B//baisuu

print(u_B-u_A)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0


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

    
baisuu=lcm(C,D)
yakusuu=math.gcd(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu

u_B=B-B//C-B//D+B//baisuu

print(u_B-u_A)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
baisuu=lcm(C,D)
yakusuu=math.gcd(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu


u_B=B-B//C-B//D+B//baisuu
# for i in range(A,baisuu):
#   if i%C!=0 and i%D!=0:
#     cnt+=1

print(u_B-u_A)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
baisuu=lcm(C,D)
yakusuu=math.gcd(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu


u_B=B-B//C-B//D+B//baisuu
# for i in range(A,baisuu):
#   if i%C!=0 and i%D!=0:
#     cnt+=1

print(u_B-u_A)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D=[int(x) for x in input().rstrip().split()]
cnt=0
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
baisuu=lcm(C,D)
yakusuu=math.gcd(C,D)

u_A=(A-1)-(A-1)//C-(A-1)//D+(A-1)//baisuu


u_B=B-B//C-B//D+B//baisuu
# for i in range(A,baisuu):
#   if i%C!=0 and i%D!=0:
#     cnt+=1

print(u_B-u_A)