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

Fixed submission:
N=int(input())
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
print(sum(num_divisors_table(N-1)))

Buggy submission (verdict: Runtime Error):
N=int(input())
import sympy
a=0
for i in range(1,N):
    a+=len(sympy.divisors(i))
print(a)
Problem p02582 (python)

Fixed submission:
S=input()
if S=="RSR":
    print(1)
else:
    
    print(len(S.replace("S","")))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split(" "))
P=list(map(int,input().split(" ")))
C=list(map(int,input().split(" ")))
count=[]
def f (i):
    q=deepcopy(i)
    count1=[]
    count2=0
    for j in range(k):
        count2+=C[i]
        count1.append(count2)
        if i==q and count1<0:
            break
        i=P[i]-1
    return max(count1)
for i in range(n):
    count.append(f(i))
print(max(count))
Problem p03037 (python)

Fixed submission:
n, m = (int(x) for x in input().split())
l = [0]*m
r = [0]*m
for i in range(m):
    l[i], r[i] = [int(x) for x in input().split()]
lmax = max(l)
rmin = min(r)
if rmin >= lmax:
    print(rmin-lmax+1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = (int(x) for x in input().split())
l = [0]*m
r = [0]*m

for i in range(m):
    l[i],r[i] = (int(x) for x in input().split())
j = 0
hoge = [0]*(r[0]-l[0]+1)

for i in range(l[0],r[0]+1):
    hoge[j] = i
    j += 1

for i in range(1,m):
    tmp = []
    k = 0
    for j in range(max(hoge[0],l[i]),min(hoge[-1],r[i])+1):
        tmp.append(j)
        k += 1
    hoge = tmp
print(len(hoge))
Problem p03076 (python)

Fixed submission:
A=[int(input())for _ in[0]*5]
B=[-(-a//10)*10-a for a in A]
print(sum(B)+sum(A)-max(B))

Buggy submission (verdict: Runtime Error):
menu = [0]*5
md = 300
time = 0
for i in range(5):
    menu[i] = int(input())
for i in range(5):
    huga = menu[i]%10
    if((huga<md)and(huga!=0)):
        x = menu[i]
        md = menu[i]%10
        index = i
#        print(md,index)
menu.pop(index)
for i in range(4):
    hoge = menu[i] % 10
    if hoge != 0:
        time = time + menu[i] + (10 - hoge)
    else:
        time = time + menu[i]

time  = time + x
print(time)

Buggy submission (verdict: Runtime Error):
menu = [0]*5
md = 300
time = 0
for i in range(5):
    menu[i] = int(input())
for i in range(5):
    if(((menu[i]%10)<md)and(menu[i]%10)!=0):
        x = menu[i]
        md = menu[i]%10
        index = i
#        print(md,index)
menu.pop(index)
for i in range(4):
    hoge = menu[i] % 10
    if hoge != 0:
        time = time + menu[i] + (10 - hoge)
    else:
        time = time + menu[i]

time  = time + x
print(time)

Buggy submission (verdict: Runtime Error):
menu = [0]*5
md = 300
time = 0
for i in range(5):
    menu[i] = int(input())
for i in range(5):
    if(((menu[i]%10)<md)and(menu[i]%10)!=0):
        md = menu[i]
        index = i
#        print(md,index)
menu.pop(index)
for i in range(4):
    hoge = menu[i] % 10
    if hoge != 0:
        time = time + menu[i] + (10 - hoge)
    else:
        time = time + menu[i]

time  = time + md
print(time)
Problem p03106 (python)

Fixed submission:
A, B ,K  = (int(x) for x in input().split())
i = 1
ans = []
while True:
    if min(A,B) < i:
        break
    if (A % i == 0) & (B % i == 0):
        ans.append(i)
    i = i + 1
print(ans[len(ans)-K])

Buggy submission (verdict: Runtime Error):
A, B ,K  = (int(x) for x in input().split())
i = 1
ans = []
while True:
    if min(A,B) < i:
        break
    if A % i == 0 & B % i == 0:
        ans.append(i)
    i = i + 1
print(ans[-K-1])
Problem p03145 (python)

Fixed submission:
side = [int(x) for x in input().split()]
side.sort()
 
print(int(side[0]*side[1]/2))

Buggy submission (verdict: Runtime Error):
ソースコード 

Copy
Copy
side = [int(x) for x in input().split()]
side.sort()
 
print(int(side[0]*side[1]/2))
Problem p03474 (python)

Fixed submission:
a,b = (int(x) for x in input().split())
s = input()
num = 0

for i in s:
    if i == '-':
        continue
    elif int(i)>= 0 and int(i)<= 9:
        num += 1
    
    

if a + b == num and s[a] == '-':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b = (int(x) for x in input().split())
s = input()
num = 0

for i in s:
    if int(s)>= 0 and int(s)<= 9:
        num += 1

if a + b == num and s[a] == '-':
    print('Yes')
else:
    print('No')
Problem p03633 (python)

Fixed submission:
n = int(input())
ans = int(input())
 
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
 
def lcm(x,y):
    return (x*y//gcd(x,y))
 
for i in range(n-1):
    t = int(input())
    ans = lcm(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = int(input())
 
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
 
def lcm(x,y):
    return (x*y//gcd(x,y))
 
for i in range(N-1):
    t = int(input())
    ans = lcm(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(num1,num2):
    if num2 == 0:
        return num1
    return gcd(num2,num1%num2)

n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

time = 1

for i in t:
    time = time * i / gcd(time,i)

print(int(time))

Buggy submission (verdict: Runtime Error):
def gcd(num1,num2):
    if num2 == 0:
        return num1
    return gcd(num2,num1%num2)

n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

time = 1

for i in t:
    time = time * i / gcd(time,i)

print(int(time))

Buggy submission (verdict: Runtime Error):
def gcd(num1,num2):
    if num2 == 0:
        return num1
    return gcd(num2,num1%num2)

n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

time = 1

for i in t:
    time = time * i / gcd(time,i)

print(time)

Buggy submission (verdict: Runtime Error):
def gcd(num1,num2):#ユークリッド互除法を関数化
    if num2 == 0:
        return num1
    return gcd(num2,num1%num2)

n = int(input())
t = [int(x) for x in input()]
time = 1

for i in t:#最大公約数を求める。　積を最小公倍数で割ればよい
    time = time * t // gcd(time,i)

Buggy submission (verdict: Runtime Error):
def gcd (num1,num2):
    tmp = max(num1,num2) % min(num1,num2)
    if tmp == 0:
        return min(num1,num2)
    return gcd(min(num1,num2),tmp)

n = int(input())
t = []
stock = [1]
for i in range(n):
    t.append(int(input()))

for i in range(len(t)-1):
    stock.append(int(t[i+1] / gcd(stock[i],t[i])*t[i]))

print(stock[-1])

Buggy submission (verdict: Runtime Error):
def gcd (num1,num2):
    tmp = max(num1,num2) % min(num1,num2)
    if tmp == 0:
        return min(num1,num2)
    return gcd(min(num1,num2),tmp)

n = int(input())
t = []
stock = [1]
for i in range(n):
    t.append(input())

for i in range(len(t)-1):
    stock.append(t[i] * t[i+1] / gcd(stock[i],t[i]))

print(stock[-1])

Buggy submission (verdict: Runtime Error):
def gcd (num1,num2):#ユークリッド互除法
    tmp = max(num1,num2) % min(num1,num2)
    if tmp == 0:
        return min(num1,num2)
    return gcd(min(num1,num2),tmp)


n = int(input())
t = []
stock = [1]
for i in range(n):
    t.append(input())

for i in range(len(t)-1):#各秒数の最大公倍数を求める
    stock.append(t[i] * t[i+1] / gcd(stock[i],t[i]))

print(stock[-1])
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
if a > b:
  print('GREATER')
elif a == b:
  print('EQUAL')
else:
  print('LESS')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a > b:
  print('GREATER')
elif a = b:
  print('EQUAL')
else:
  print('LESS')
Problem p03814 (python)

Fixed submission:
s = list(input())
flagA = False
flagZ = False

if s[0] == 'A':
    a = 0
    flagA = True

# 文字列の両端から探索していきAのうち最左端にあるものZのうち最右端にあるものの要素数を記録　O(N/2)
i = 1
while not (flagA == True and flagZ == True):

    if s[i] == 'A' and flagA == False:
        a = i 
        flagA = True 
    if s[-i] == 'Z' and flagZ == False:
        z = len(s) - i
        flagZ = True
    
    i += 1
print(z-a+1)

Buggy submission (verdict: Runtime Error):
s = list(input())
flagA = False
flagZ = False

if s[0] == 'A':
    flagA = True

# 文字列の両端から探索していきAのうち最左端にあるものZのうち最右端にあるものの要素数を記録　O(N/2)
i = 1
while not (flagA == True and flagZ == True):

    if s[i] == 'A' and flagA == False:
        a = i 
        flagA = True 
    if s[-i] == 'Z' and flagZ == False:
        z = len(s) - i
        flagZ = True
    
    i += 1
print(z-a+1)
Problem p03957 (python)

Fixed submission:
n = input()

cflag = False

for i in range(len(n)):
    if n[i] == 'C':
        cflag = True
    elif cflag == True and n[i] == 'F':
        print('Yes')
        exit()

print('No')

Buggy submission (verdict: Runtime Error):
n = input().split()

for i in range(len(n)):
    if n[i] == 'C':
        cflag = 1
    elif cflag == 1 and n[i] == 'F':
        print('Yes')
        exit()

print('No')
Problem p02641 (python)

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

if n == 0:
    print(x)
    exit()

p.sort()

for i in range(p[0] - x, p[n - 1] + x):
    if (i not in p) and abs(x - i) < abs(ans - x):
        ans = i

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
p.sort()
for i in range(p[0], p[n - 1] + 1):
    if (i not in p) and abs(x - i) < abs(ans - x):
        ans = i

print(ans)
Problem p02690 (python)

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

for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if math.pow(a, 5) == x + math.pow(b, 5):
            print(a, b)
            exit()

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

for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if math.pow(a, 5) == x + math.pow(b, 5):
            print(a, b)
            exit()
Problem p02731 (python)

Fixed submission:
l = int(input())
print(l/3*l/3*l/3)

Buggy submission (verdict: Runtime Error):
l = int(input())
print((l/3)^3)
Problem p02765 (python)

Fixed submission:
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100 * (10 - n))

Buggy submission (verdict: Runtime Error):
n, r = map(int, input())
if n >= 10:
    print(r)
else:
    print(r + 100 * (10 - n))
Problem p02767 (python)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1] + 1):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)
print(min(sigmaList))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))
Problem p02772 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
flg = True
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            flg = False
            break

if flg:
    print("APPROVED")
else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            print("APPROVED")
    else:
        print("DENIED")
Problem p02801 (python)

Fixed submission:
c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        break
    elif c == "z":
        print("a")
        break

Buggy submission (verdict: Runtime Error):
c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        flg = False
    elif c == "z":
        print("a")
        flg = False

Buggy submission (verdict: Runtime Error):
c = input()
s = 'abcdefghijklmnopqrstuvwxyz'
flg = True
while flg:
    if c == s[i] and c != 'z':
        print(s[i + 1])
        flg = False
    elif c == 'z':
        print('a')
        flg = False

Buggy submission (verdict: Runtime Error):
c = input()
s = 'abcdefghijklmnopqrstuvwxyz'
flg = True
while flg:
    if c == s[i] and c != 'z':
        print(s[i + 1])
        flg = False
    elif c == 'z':
        print('a')
        flg = False
Problem p02947 (python)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [str(input()) for _ in range(n)]
t = []
ans = 0
for i in range(n):
    s[i] = sorted(s[i])

t = set(s)
ans = len(s) - len(t)


print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [str(input()) for _ in range(n)]
t = []
ans = 0
for i in range(n):
    s[i] = sorted(s[i])

t = set(s)
ans = len(s) - len(t)


print(ans)
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                count += 1

print(count)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                count += 1

print(count) 2
Problem p02582 (python)

Fixed submission:
s = input()
if s == 'RRR':
  print(3)
elif s == 'RRS' or s == 'SRR':
  print(2)
elif s == 'SSS':
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
s = input()
if s == 'RRR':
  return 3
elif s == 'RRS' or s == 'SRR':
  return 2
elif s == 'SSS':
  return 0
else:
  return 1
Problem p02702 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

def calc(S):
    N = len(S)
    r = 0
    d = [0] * 2019
    p = 1
    d[0] = 1
    for i in range(N):
        r = (r + int(S[N - 1 - i]) * p) % 2019
        p = (p * 10) % 2019
        d[r] += 1
    ans = 0
    for c in d:
        ans += c * (c - 1) // 2
    return ans


S = input()
print(calc(S))

Buggy submission (verdict: Runtime Error):
import sys

def calc(S):
    N = len(S)
    r = 0
    d = [0] * 2019
    d[0] = 1
    for i in range(N):
        r = (r + int(S[N - 1 - i]) * 10 ** i) % 2019
        d[r] += 1
    ans = 0
    for c in d:
        ans += c * (c - 1) // 2
    return ans


S = sys.stdin.readline() # input()
print(calc(S))
Problem p02866 (python)

Fixed submission:
Z = 998244353


def calc(N, D):
    if D[0] != 0:
        return 0
    d = {}
    for Di in D:
        d[Di] = 1 + (d[Di] if Di in d else 0)
    if d[0] != 1:
        return 0
    result = 1
    for i in range(max(d.keys())):
        if not i + 1 in d:
            return 0
        result *= (d[i] ** d[i + 1]) % Z
        result = result % Z
    return result


N = int(input())
D = [int(s) for s in input().split()]
print(calc(N, D))

Buggy submission (verdict: Runtime Error):
def calc(N, D):
    if D[0] != 0:
        return 0
    d = {}
    for Di in D:
        d[Di] = 1 + (d[Di] if Di in d else 0)
    if d[0] != 1:
        return 0
    result = 1
    for i in range(max(d.keys())):
        if d[i + 1] == 0:
            return 0
        result *= d[i] ** d[i + 1]
    return result


N = int(input())
D = [int(s) for s in input().split()]
print(calc(N, D))
Problem p02882 (python)

Fixed submission:
import math as m


def calc(a, b, x):
    if x > a * a * b / 2:
        y = 2 * (a * a * b - x) / a ** 3
        return m.degrees(m.atan(y))
    else:
        y = a * b * b / 2 / x
        return m.degrees(m.atan(y))


(a, b, x) = tuple([int(s) for s in input().split()])
print(calc(a, b, x))

Buggy submission (verdict: Runtime Error):
def calc(a, b, x):
    if x > a * a * b / 2:
        y = 2 * (a * a * b - x) / a ** 3
        return m.degrees(m.atan(y))
    else:
        y = a * b * b / 2 / x
        return m.degrees(m.atan(y))


(a, b, x) = tuple([int(s) for s in input().split()])
print(calc(a, b, x))
Problem p02975 (python)

Fixed submission:
def calc(N, A):
    _exist = False
    counter = {}
    for a in A:
        counter[a] = 1 + (counter[a] if a in counter else 0)
    if (N % 3 == 0 and len(counter) == 3):
        keys = list(counter.keys())
        values = list(counter.values())
        d = max(values) - min(values)
        _exist = d == 0 and keys[0] ^ keys[1] == keys[2]
    elif (N % 3 == 0 and len(counter) == 2):
        keys = list(counter.keys())
        values = list(counter.values())
        d = max(values) - min(values)
        _exist = d == N // 3 and (keys[0] == 0 or keys[1] == 0)
    else:
        _exist = 0 in counter and counter[0] == N
    print('Yes' if _exist else 'No')


N = int(input())
A = [int(s) for s in input().split(' ')]
calc(N, A)

Buggy submission (verdict: Runtime Error):
def calc(N, A):
    _exist = False
    counter = {}
    for a in A:
        counter[a] = 1 + (counter[a] if a in counter else 0)
    keys = counter.keys()
    values = counter.values()
    d = max(values) - min(values)
    if (N % 3 == 0 and len(counter) == 3 and d == 0):
        _exist = keys[0] ^ keys[1] == keys[2]
    else:
        _exist = 0 in counter and counter[0] == N
    print('Yes' if _exist else 'No')


N = int(input())
A = [int(s) for s in input().split(' ')]
calc(N, A)

Buggy submission (verdict: Runtime Error):
def calc(N, A):
    _exist = False
    counter = {}
    for a in A:
        counter[a] = 1 + (counter[a] if a in counter else 0)
    keys = counter.keys()
    values = counter.values()
    d = max(values) - min(values)
    if (N % 3 == 0 and d == 0):
        _exist = keys[0] + keys[1] == keys[2]
    else:
        _exist = 0 in counter and counter[0] == N
    print('Yes' if _exist else 'No')


N = int(input())
A = [int(s) for s in input().split(' ')]
calc(N, A)
Problem p03005 (python)

Fixed submission:
splited = input().split(' ')
N = int(splited[0])
K = int(splited[1])
 
if(K == 1):
    print(0)
else:
    print(N - K)

Buggy submission (verdict: Runtime Error):
splited = input().split(' ')
N = int(splited[0])
K = int(splited[1])
 
if(K == 1):
    print(0)
else
    print(N - K)

Buggy submission (verdict: Runtime Error):
splited = input().split(' ')
N = int(splited[0])
K = int(splited[1])

if(K == 1):
    return 0
else
    return N - K
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split(' '))
r1=b-b%c
if a%c!=0:
	l1=a-a%c+c
else:
	l1=a
r2=b-b%d
if a%d!=0:
	l2=a-a%d+d
else:
	l2=a
lcm=(c*d)//gcd(c,d)
r3=b-b%lcm
if a%lcm!=0:
	l3=a-a%lcm+lcm
else:
	l3=a
nc=(r1-l1+c)//c
nd=(r2-l2+d)//d
nlcm=(r3-l3+lcm)//lcm
divi=nc+nd-nlcm
out=b-a+1
if c>a and c>b and d>a and d>b:
	print(0)
else:
	print(out-divi)

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b,c,d=map(int,input().split(' '))
r1=b-b%c
if a%c!=0:
	l1=a-a%c+c
else:
	l1=a
r2=b-b%d
if a%d!=0:
	l2=a-a%d+d
else:
	l2=a
lcm=(c*d)//gcd(c,d)
r3=b-b%lcm
if a%lcm!=0:
	l3=a-a%lcm+lcm
else:
	l3=a
nc=(r1-l1+c)//c
nd=(r2-l2+d)//d
nlcm=(r3-l3+lcm)//lcm
divi=nc+nd-nlcm
out=b-a+1
if c>a and c>b and d>a and d>b:
	print(0)
else:
	print((out-divi)%(10**9+7))

Buggy submission (verdict: Runtime Error):
# Recursive function to return gcd of a and b 
def gcd(a,b): 
	
	# Everything divides 0 
	if (a == 0): 
		return b 
	if (b == 0): 
		return a 

	# base case 
	if (a == b): 
		return a 

	# a is greater 
	if (a > b): 
		return gcd(a-b, b) 
	return gcd(a, b-a) 

#from math import gcd
a,b,c,d=map(int,input().split(' '))
r1=b-b%c
if a%c!=0:
	l1=a-a%c+c
else:
	l1=a
r2=b-b%d
if a%d!=0:
	l2=a-a%d+d
else:
	l2=a

lcm=(c*d)//gcd(c,d)
r3=b-b%lcm
if a%lcm!=0:
	l3=a-a%lcm+lcm
else:
	l3=a
nc=(r1-l1+c)//c
nd=(r2-l2+d)//d
nlcm=(r3-l3+lcm)//lcm
divi=nc+nd-nlcm
out=b-a+1
if c>a and c>b and d>a and d>b:
	print(0)
else:
	print(out-divi)

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b,c,d=map(int,input().split(' '))
r1=b-b%c
if a%c!=0:
	l1=a-a%c+c
else:
	l1=a
r2=b-b%d
if a%d!=0:
	l2=a-a%d+d
else:
	l2=a
lcm=(c*d)//gcd(c,d)
r3=b-b%lcm
if a%lcm!=0:
	l3=a-a%lcm+lcm
else:
	l3=a
nc=(r1-l1+c)//c
nd=(r2-l2+d)//d
nlcm=(r3-l3+lcm)//lcm
divi=nc+nd-nlcm
out=b-a+1
if c>a and c>b and d>a and d>b:
	print(0)
else:
	print(out-divi)

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b,c,d=map(int,input().split( ))
r1=b-b%c
if a%c!=0:
	l1=a-a%c+c
else:
	l1=a
r2=b-b%d
if a%d!=0:
	l2=a-a%d+d
else:
	l2=a
lcm=(c*d)//gcd(c,d)
r3=b-b%lcm
if a%lcm!=0:
	l3=a-a%lcm+lcm
else:
	l3=a
nc=(r1-l1+c)//c
nd=(r2-l2+d)//d
nlcm=(r3-l3+lcm)//lcm
divi=nc+nd-nlcm
out=b-a+1
if c>a and c>b and d>a and d>b:
	print(0)
else:
	print(out-divi)

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b,c,d=map(int,input().split( ))
r1=b-b%c
if a%c!=0:
	l1=a-a%c+c
else:
	l1=a
r2=b-b%d
if a%d!=0:
	l2=a-a%d+d
else:
	l2=a
lcm=(c*d)//gcd(c,d)
r3=b-b%lcm
if a%lcm!=0:
	l3=a-a%lcm+lcm
else:
	l3=a
nc=(r1-l1+c)//c
nd=(r2-l2+d)//d
nlcm=(r3-l3+lcm)//lcm
divi=nc+nd-nlcm
out=b-a+1
print(out-divi)
Problem p02553 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
print(max(a*c,a*d,b*c,b*d))

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
print(max(a*c,a*d,b*c,b*d)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input())
print(max(a*c,a*d,b*c,b*d))
Problem p02618 (python)

Fixed submission:
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))

def last(d,la):
    s = 0

    for i in range(26):
        if la[i] == 0 and  i == d:
            s += c[i] * (d - la[i]-1)
        else:
            s += c[i] * (d - la[i])
    return s

lastday = [0]*26
a = 0

for d in range(D):

    eff = s[d][0] - last(d+1,lastday)
    ret = 0
    for t in range(26):
        bef = lastday[t]
        #lastday[t] = d+1
        
        now = s[d][t] - last(d+1,lastday)
        if eff < now:
            eff = now 
            ret = t

        lastday[t] = bef
        
    lastday[ret] = d+1
    a += eff
    print(ret+1)

Buggy submission (verdict: Runtime Error):
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))

def last(d,la):
    s = 0

    for i in range(26):
        if la[i] == 0 and  i == d:
            s += c[i] * (d - la[i]-1)
        else:
            s += c[i] * (d - la[i])
    return s

lastday = [0]*26
a = 0

for d in range(D):

    eff = s[d][0] - last(d+1,lastday)
    ret = 0
    for t in range(26):
        bef = lastday[t]
        #lastday[t] = d+1
        
        now = s[d][t] - last(d+1,lastday)
        if eff < now:
            eff = now 
            ret = t

        lastday[t] = bef
        
    lastday[ret] = d+1
    a += eff
    print(ret+1

Buggy submission (verdict: Runtime Error):
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))

def last(d,la):
    s = 0
    for i in range(26):
        s += c[i] * (d - la[i])
    return s

lastday = [0]*26
a = 0

for d in range(D):

    eff = s[d][0] - last(d+1,lastday)
    for t in range(26):
        bef = lastday[t]
        lastday[t] = d+1

        now = s[d][t] - last(d+1,lastday)
        if eff < now:
            eff = now 
            ret = t

        lastday[t] = bef
        
    lastday[ret] = d+1
    a += eff
    print(ret+1)