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

Fixed submission:
def gcd(x,y):
     if x%y==0:
             return y
     else:
             return gcd(y, x%y)

[n,m]=[int(i) for i in input().split()]
x=[int(i)-m for i in input().split()]
x.append(0)

li=[]
f=1
if n==1:
    f=0
    print(abs(x[0]-x[1]))

for i in range(len(x)-1):
    li.append(max(abs(x[i]-x[i+1]), (abs(x[i+1]-x[i]))))
temp=abs(min(x))
li.append(temp)


if f:
    a=li[0]
    for i in range(len(li)-1):
        a=gcd(a, li[i+1])
    print(a)

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
     if x%y==0:
             return y
     else:
             return gcd(y, x%y)

[n,m]=[int(i) for i in input().split()]
x=[int(i)-m for i in input().split()]
x.append(0)

li=[]
f=1
if n==1:
    f=0
    print(abs(x[0]-x[1]))

for i in range(len(x)-1):
    li.append(abs(x[i]-x[i+1]))
temp=abs(min(x))
li.append(temp)
try:
    x.remove(temp)
except:
    x.remove(-temp)
temp=abs(min(x))
li.append(temp)



if f:
    for i in range(len(li)-1):
        a=li[0]
        a=gcd(a, li[i+1])
    print(a)
Problem p03288 (python)

Fixed submission:
r=int(input())

if r<1200:
    print("ABC")
elif r<2800:
    print("ARC")
else:
    print("AGC")

Buggy submission (verdict: Runtime Error):
r=int(imput())

if r<1200:
    print("ABC")
elif r<2800:
    print("ARC")
else:
    print("AGC")
Problem p03294 (python)

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


def lcm(x, y):
    x2=x
    y2=y
    while y != 0:
        x, y = y, x%y
    return (x2 * y2) // x

while(len(ac)>1):
    x=ac.pop()
    y=ac.pop()
    ac.append(lcm(x, y))

g=ac[0]-1

ans=0
for i in a:
    ans+=g%i

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n=input()
a=[int(i) for i in input().split()]
ac=a[:]


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

while(len(ac)>1):
    x=ac.pop()
    y=ac.pop()
    ac.append(lcm(x, y))

g=ac[0]-1

ans=0
for i in a:
    ans+=g%i

print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
a=[int(i) for i in input().split()]

import math
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

g=lcm(*a)-1

ans=0
for i in a:
    ans+=g%i

print(ans)
Problem p03353 (python)

Fixed submission:
s=input()
k=int(input())

li=[]
for i in range(len(s)):
    for j in range(1, k+1):
        li.append(s[i:i+j])

se=set(li)
sli=list(se)
sli.sort()
#print(sli)
print(sli[k-1])

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

li=[]
if len(s)<=k:
    iif=0
else:
    iif=k
for i in range(len(s)):
    for j in range(1, len(s)-iif+1):
        li.append(s[i:i+j])
        #print(s[i:i+j])

se=set(li)
sli=list(se)
sli.sort()
#print(sli)
print(sli[k-1])
Problem p03280 (python)

Fixed submission:
a,b=map(int,input().split())
print(a*b-a-b+1)

Buggy submission (verdict: Runtime Error):
a,b=map(int,intput().split())
print(a*b-a-b+1)
Problem p02658 (python)

Fixed submission:
a=int(input())
b=list(map(int,input().split()))
b.sort()
ans=1
for i in range(a):
  ans=ans*b[i]
  if ans>10**18:
    ans=-1
    break
  
print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=list(map(int,input().split()))
ans=1
for i in range(a):
  ans=ans*b[i]
  if ans>10**18:
  	ans=-1
    break
  
print(ans)
Problem p02882 (python)

Fixed submission:
import math
a,b,c=map(int,input().split())
d=b-c/(a**2)
d=d*2
if d==0:
  print(0)
elif d>b:
  e=(c*2)/(a*b)
  print(math.degrees(math.atan(b/e)))
else:
  print(math.degrees(math.atan(d/a)))

Buggy submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
d=b-c/(a**2)
d=d*2
if d==0:
  print(0)
if d>a:
  e=c*2/(a*b)
  print(90-math.degrees(math.atan(e/b)))
else:
  print(90-math.degrees(math.atan(a/d)))
Problem p02883 (python)

Fixed submission:
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
c.sort()
d.sort(reverse=True)
e=[0 for i in range(a)]
for i in range(a):
  e[i]=c[i]*d[i]
def s(e,x):
  k=0
  for i in range(a):
    if e[i]<x:
      continue
    else:
      k+=math.ceil((e[i]-x)/d[i])
  if k>b:
    return False
  else:
    return True
    
left=0
right=max(e)
while left!=right:
  mid=(left+right)//2
  if s(e,mid):
    right=mid
  else:
    left=mid+1
print(left)

Buggy submission (verdict: Runtime Error):
import heapq
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(map(int,input().split()))
if b>=sum(c):
  print(0)
else:
  c.sort()
  d.sort(reverse=True)
  e=[c[i]*d[i] for i in range(a)]
  f=[]
  for i in range(a):
    heapq.heappush(f,-e[i])
  k=0
  while k<b or f[0]==0:
    x=-heapq.heappop(f)
    y=e.index(x)
    z=min(b-k,(x+f[0])//d[y]+1)
    k+=z
    c[y]=c[y]-z
    e[y]=c[y]*d[y]
    heapq.heappush(f,-e[y])
    print(f)
  print(-f[0])
Problem p02936 (python)

Fixed submission:
from collections import deque
a,b=map(int,input().split())
e=[[]for i in range(a)]

for i in range(a-1):
  c1,c2=map(int,input().split())
  e[c1-1].append(c2-1)
  e[c2-1].append(c1-1)

g=[[]for i in range(a)]
f=deque()
f.append((0,-1))
ans=[0 for _ in range(a)]
for i in range(b):
  ten,p=map(int,input().split())
  ans[ten-1]+=p
i=0
while len(f)!=0:
  i,fr=f.popleft()
  for j in e[i]:
    if j==fr:
      continue
    else:
      ans[j]+=ans[i]
      f.append([j,i]) 
print(*ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a-1)]
d=[list(map(int,input().split())) for i in range(b)]
e=[[]for i in range(a)]

for i in c:
  e[i[0]-1].append(i[1]-1)
  e[i[1]-1].append(i[0]-1)


g=[[i]for i in range(a)]

def s(i,e,f):
  for j,k in enumerate(e[i]):
    if f==k:
      e[i].pop(j)
      break
  if e[i]==[]:
    return []
  global g
  g[i]=g[i]+e[i]
  for j in e[i]:
    g[i]=g[i]+s(j,e,i)
  return e[i]


s(0,e,0) 
h=[0 for i in range(a)]
for i in d:
  for j in g[i[0]-1]:
    h[j]+=i[1]
    
print(" ".join(map(str,h)))
Problem p02975 (python)

Fixed submission:
a=int(input())
b=list(map(int, input().split()))
c=list(set(b))
t=0
d=[0 for i in range(len(c))]
if a==1:
  print("Yes")
else:
  if len(c)==1:
    if c[0]==0:
      print("Yes")
    else:
      print("No")
  elif len(c)==2:
    for i in range(len(c)):
      e=c[i]
      d[i]=b.count(e)
    if (c[0]==0 and d[0]*2==d[1])or (c[1]==0 and d[1]*2==d[0]):
      print("Yes")
    else:
      print("No")
  elif len(c)>3:
    print("No")
  else:  
    for i in range(len(c)):
      e=c[i]
      d[i]=b.count(e)
    if d[0]==d[1]and d[0]==d[2] and c[0]==c[1]^c[2]:
      print("Yes")
    else:
      print("No")

Buggy submission (verdict: Runtime Error):
import copy
a=int(input())
b=(list(map(int, input().split())))
bb = copy.copy(b)
c=0
d=[]
n=0
f=b[0]
d.append(f)
b.pop(0)
print(1^2)
print(2^3)
print(3^1)

def kakunin(bb,d):
  while c==0:
    cc=0
    for i in range(len(bb)):
      print(d)
      if d[len(d)-2]==d[len(d)-1]^bb[i]:
        g=bb[i]
        d.append(g)
        bb.pop(i)
        cc=1
        if len(d)==a and d[0]==d[len(d)-2]^d[len(d)-1]:
          global ccc
          ccc=1
          return
        break
    if cc==0:
      ccc=0
      return
      
while c==0:
  n+=1    
  bb = copy.copy(b)
  f=b[0]
  d.append(f)
  b.pop(0)
  bb.pop(0)
  kakunin(bb,d)
  b.append(f)
  if ccc==1:
    print("Yes")
    break
  else:
    d=[f]
  if n>=a:
    print("No")
    break

Buggy submission (verdict: Runtime Error):
import copy
a=int(input())
b=(list(map(int, input().split())))
bb = copy.copy(b)
c=0
d=[]
n=0
f=b[0]
d.append(f)
b.pop(0)

def kakunin(bb,d):
  while c==0:
    cc=0
    for i in range(len(bb)):
      if d[len(d)-2]==d[len(d)-1]^bb[i]:
        g=bb[i]
        d.append(g)
        bb.pop(i)
        cc=1
        if len(d)==a and d[0]==d[len(d)-2]^d[len(d)-1]:
          global ccc
          ccc=1
          return
    if cc==0:
      ccc=0
      return
      
while c==0:
  n+=1    
  bb = copy.copy(b)
  f=b[0]
  d.append(f)
  b.pop(0)
  bb.pop(0)
  kakunin(bb,d)
  b.append(f)
  if ccc==1:
    print("Yes")
    break
  else:
    d=[f]
  if n>=a:
    print("No")
    break
Problem p03493 (python)

Fixed submission:
a,b,c=input()
a=int(a)
b=int(b)
c=int(c)
print(a+b+c)

Buggy submission (verdict: Runtime Error):
a,b,c=int(input())
print(a+b+c)
Problem p03574 (python)

Fixed submission:
a,b=map(int,input().split())
c=[str(input()) for i in range(a)]
for i in range(a):
  c[i]="."+c[i]+"."
c=["."*(b+2)]+c +["."*(b+2)]
d=[["0"for i in range(b)]for j in range(a)]
for i in range(1,a+1):
  for j in range(1,b+1):
    f=0
    for k in range(-1,2):
      for l in range(-1,2):
        if c[i+k][j+l]=="#":
          f+=1
    d[i-1][j-1]=str(f)
for i in range(1,a+1):
  for j in range(1,b+1):
    if c[i][j]=="#":
      d[i-1][j-1]="#"
for i in range(a):
  dd=""
  for j in range(b):
    dd+=str(d[i][j])
  print(dd)

Buggy submission (verdict: Runtime Error):
a,b=[int(input()) for i in range(2)]
c=[str(input()) for i in range(a)]
for i in range(a):
  c[i]="."+c[i]+"."
c=["."*(b+2)]+c +["."*(b+2)]
d=[["0"for i in range(b)]for j in range(a)]
for i in range(1,a+1):
  for j in range(1,b+1):
    f=0
    for k in range(-1,2):
      for l in range(-1,2):
        if c[i+k][j+l]=="#":
          f+=1
    d[i-1][j-1]=str(f)
for i in range(1,a+1):
  for j in range(1,b+1):
    if c[i][j]=="#":
      d[i-1][j-1]="#"
for i in range(a):
  dd=""
  for j in range(b):
    dd+=str(d[i][j])
  print(dd)

Buggy submission (verdict: Runtime Error):
a,b=[int(input()) for i in range(2)]
c=[str(input()) for i in range(a)]
for i in range(a):
  c[i]="."+c[i]+"."
c=["."*(b+2)]+c +["."*(b+2)]
d=[[0 for i in range(b)] for j in range(a)]

for i in range(1,a+2):
  for j in range(1,b+2):
    for k in range(-1.2):
      for l in range(-1,2):
        if c[i+k[j+l]]=="#"
          d[i-1[j-1]]+=1
          
for i in range(1,a+2):
  for j in range(1,b+2):
    if c[i[j]]=="#":
      d[i-1[j-1]]="#"
      
print(d)
Problem p02658 (python)

Fixed submission:
def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.count(0)>=1:
        print(0)
        return

    for i in range(N):
        cal*=a[i]
        if cal>10**18:
            print("-1")
            return

    print(cal)
    return


main()

Buggy submission (verdict: Runtime Error):
def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.index(0)==1:
        print(0)
        return

    for i in range(N):
        cal*=a[i]
        if cal>=10**18:
            print("-1")
            return

    print(cal)
    return


main()

Buggy submission (verdict: Runtime Error):
def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

    if a.index(0):
        print(0)
        return
        
    for i in range(N):
        cal*=a[i]
        if cal>=10**18:
            print("-1")
            return

    print(cal)
    return


main()
Problem p02684 (python)

Fixed submission:
def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    cal=0
    time=[0]*N
    town=[]
    roop=[]

    while time[cal]!=2:
        if time[cal]==0:
            town.append(cal)

        else :
            roop.append(cal)

        time[cal]+=1
        cal=A[cal]-1

    if len(town)>K:
        print(town[K]+1)
        return

    else :
        print(roop[(K-(len(town)-len(roop)))%len(roop)]+1)
        return
main()

Buggy submission (verdict: Runtime Error):
def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    cal=0
    time=[0]*N
    town=[]
    roop=[]

    while time[cal]!=2:
        if time[cal]==0:
            town.append(cal)

        else :
            roop.append(cal)

        time[cal]+=1
        cal=A[cal]-1
    if len(time)>K:
        print(town[K]+1)
        return

    else :
        print(roop[(K-(len(town)-len(roop)))%len(roop)]+1)
        return
main()

Buggy submission (verdict: Runtime Error):
def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    cal=0
    time=[0]*N
    town=[]
    roop=[]

    while time[cal]!=2:
        if time[cal]==0:
            town.append(cal)

        else :
            roop.append(cal)

        time[cal]+=1
        cal=A[cal]-1

    if N>K:
        print(town[K]+1)
        return

    else :
        print(roop[(K-(len(town)-len(roop)))%len(roop)]+1)
        return
main()
Problem p02696 (python)

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

x=min(N,B-1)

ans=((A*x)//B)-(A*(x//B))
print(ans)

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

for i in range(1,120):
    for j in range(-120,120):
        if ((i**5)-(j**5))==x:
            print(i, j)
            exit()
Problem p02755 (python)

Fixed submission:
import math
A,B=map(int,input().split())
cal,cal2=0,0
ans=[]

for i in range(1200):
    cal=math.floor(i*0.08)
    cal2=math.floor(i*0.1)

    if cal==A and cal2==B:
        ans.append(i)


if len(ans)>0:
    print(min(ans))
else :
    print(-1)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
cal,cal2=0,0
ans=[]

for i in range(1200):
    cal=math.floor(i*0.08)
    cal2=math.floor(i*0.1)

    if cal==A and cal2==B:
        ans.append(i)


if len(ans)>0:
    print(min(ans))
else :
    print(-1)
Problem p02760 (python)

Fixed submission:
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
i,j,k,c,z=0,0,0,0,0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]=="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]=="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]=="x":
        c+=1
    if a[z][0]==a[z][1]==a[z][2]=="x":
        c+=1
if c!=0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
i,j,k,c,z=0,0,0,0,0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]=="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]=="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]=="x":
        c+=1
    if a[z]][0]==a[z][1]==a[z][1s]=="x":
        c+=1
if c!=0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
i,j,k,c,z=0,0,0,0,0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]=="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]=="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]=="x":
        c+=1

if c!=0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
c=0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]="x":
        c+=1

if c!=0:
    print("Yes")
else:
    print("No")
Problem p02814 (python)

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


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


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    t = 1
    for a in A:
        if a & 1:
            print(0)
            return
        else:
            t = lcm(t, a//2)
    for a in A:
        if t % a == 0:
            print(0)
            exit()

    ans = M//t/2
    ans = -(-ans//1)
    print(int(ans))


if __name__ == '__main__':
    main()

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


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


def main():
    N, M = map(int, input().split())
    tmp = list(map(int, input().split()))
    A = []
    for i in tmp:
        if i % 2 == 0:
            A.append(i)
    d = A[0]
    for a in A:
        d = lcm(d, a)
    ans = (2*M)//d/2
    ans = -(-ans//1)
    print(int(ans))


if __name__ == '__main__':
    main()
Problem p02850 (python)

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


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        G[a-1].append((b-1, i))
        G[b-1].append((a-1, i))

    V = [[-1, -1] for _ in range(N)]  # 頂点の[親, 親への辺の色]
    ans = [-1]*(N-1)
    import collections
    Q = collections.deque()
    Q.append(0)
    while Q:
        i = Q.popleft()
        color = 0
        for c, ei in G[i]:
            if c == V[i][0]:
                continue
            V[c][0] = i
            color += 1
            if color == V[i][1]:
                color += 1
            V[c][1] = ans[ei] = color
            Q.append(c)
    print(max(ans))
    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    C = [set() for _ in range(N)]
    E = [[] for _ in range(N)]
    E2 = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        E[a-1].append(b-1)
        E[b-1].append(a-1)
        E2.append([a-1, b-1])
#    print(E)
#    print(E2)
    K = 0
    for e in E:
        K = max(K, len(e))
    print(K)
    S = []
    for _ in range(N):
        s = set()
        for i in range(1, K+1):
            s.add(i)
        S.append(s)
    for a, b in E2:
        s = s[a]
        s -= C[a]
        s -= C[b]
        c = s.pop()
        print(c)
        C[a].add(c)
        C[b].add(c)


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    C = [set() for _ in range(N)]
    E = [[] for _ in range(N)]
    E2 = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        E[a-1].append(b-1)
        E[b-1].append(a-1)
        E2.append([a-1, b-1])
#    print(E)
#    print(E2)
    K = 0
    for e in E:
        K = max(K, len(e))
    print(K)
    for a, b in E2:
        s = set()
        for i in range(1, K+1):
            s.add(i)
        s -= C[a]
        s -= C[b]
        c = s.pop()
        print(c)
        C[a].add(c)
        C[b].add(c)


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    C = [set() for _ in range(N)]
    E = [[] for _ in range(N)]
    E2 = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        E[a-1].append(b-1)
        E[b-1].append(a-1)
        E2.append([a-1, b-1])
#    print(E)
#    print(E2)
    K = 0
    for e in E:
        K = max(K, len(e))
    print(K)
    s = set()
    for i in range(1, K+1):
        s.add(i)
    for a, b in E2:
        s2 = s.copy()
        s2 -= C[a]
        s2 -= C[b]
        c = s2.pop()
        print(c)
        C[a].add(c)
        C[b].add(c)


if __name__ == '__main__':
    main()
Problem p02995 (python)

Fixed submission:
import fractions

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

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

x = (b//c - (a-1)//c) + (b//d - (a-1)//d -(b//lcm(c,d)) + (a-1)//lcm(c,d))
print(b-a+1-x)

Buggy submission (verdict: Runtime Error):
import math

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

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

x = (b//c - (a-1)//c) + (b//d - (a-1)//d -(b//lcm(c,d)) + (a-1)//lcm(c,d))
print(b-a+1-x)

Buggy submission (verdict: Runtime Error):
import math

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

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

mc = B//C - (A-1)//C
md = B//D - (A-1)//D
mcd = B//lcm(C,D) - (A-1)//lcm(C,D)

print(B-A+1-mc-md+mcd)

Buggy submission (verdict: Runtime Error):
import math

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

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

mc = B//C - A//C
if A%C == 0:
    mc += 1
md = B//D - A//D
if A%D == 0:
    mc += 1

mcd = B//lcm(C,D) - A//lcm(C,D)
if A%lcm(C,D) == 0:
    mcd += 1

print(B-A+1-mc-md+mcd)
Problem p03000 (python)

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

d = 0
k = 1
for i in L:
    d += i
    if d <= X:
        k += 1
    else:
        break
print(k)

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

d = 0
k = 1
for i in range(N+1):
    d += L[i]
    if d <= X:
        k += 1
    else:
        break
print(k)
Problem p03001 (python)

Fixed submission:
w,h,x,y= map(int, input().split())

k = 0
if x == w/2 or y == h/2:
    k = 0
if x == w/2 and y == h/2:
    k = 1

print("%f %d" %(w*h/2, k))

Buggy submission (verdict: Runtime Error):
w,h,x,y= map(int, input().split())

d=w*h/2
if x == w/2 or y == h/2:
    k = 0
if x == w/2 and y == h/2:
    k = 1
print(d, k)
Problem p03006 (python)

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


def main():
    N = int(input())
    A = []
    for _ in range(N):
        x, y = map(int, input().split())
        A.append((x, y))
    if N == 1:
        print(1)
        return

    A.sort()
    import collections
    D = collections.defaultdict(int)
    import itertools
    for a, b in itertools.combinations(A, 2):
        p = a[0] - b[0]
        q = a[1] - b[1]
        D[(p, q)] += 1
    d = sorted(D.values())
    print(N - d[-1])


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    A = []
    for _ in range(N):
        x, y = map(int, input().split())
        A.append((x, y))

    import collections
    D = collections.defaultdict(int)
    import itertools
    for a, b in itertools.combinations(A, 2):
        p = a[0] - b[0]
        q = a[1] - b[1]
        D[(p, q)] += 1
    d = sorted(D.values())
    print(N - d[-1])


if __name__ == '__main__':
    main()