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

Fixed submission:
#c
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
   
    if S[i] == "A" :
        A_flag = True
    else:
        A_flag = False
    S_count.append(count)

for i in range(Q):
    print(S_count[R[i] - 1] - S_count[L[i] - 1])

Buggy submission (verdict: Runtime Error):
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
    else:
        if S[i] == "A" :
            A_flag = True
        else:
            A_flag = False
    S_count.append(count)

for i in range(Q):
    print(S_count[R[i]] - S_count[L[i]])

Buggy submission (verdict: Runtime Error):
#c
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
    else:
        if S[i] == "A" :
            A_flag = True
        else:
            A_flag = False
    S_count = count

for i in range(Q):
    print(S_count[R[i]] - S_count[L[i]])

Buggy submission (verdict: Runtime Error):
N,Q = list(map(int,input().split()))
S = input()
L = []
R = []
for i in range(Q):
    a = list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])

S_count = []
count = 0
A_flag = False

for i in range(len(S)):
    if A_flag == True:
        if S[i] == "C" :
            count += 1
    else:
        if S[i] == "A" :
            A_flag = True
        else:
            A_flag = False
    S_count = count

for i in range(Q):
    print(S[R[i]] - S[L[i]])
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
    print("Hello World")
else :
    A  = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print("Hello World")
else :
    A , B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input)
if N == 1:
    print("Hello World")
else :
    A , B = int(input)
    print(A+B)
Problem p03243 (python)

Fixed submission:
a = int(input())
b = int(a /100)
if a > (100*b + 10*b +b ):
    print(100*(b+1) + 10*(b+1) +b +1)
else:
    print(100*b + 10*b + b)

Buggy submission (verdict: Runtime Error):
a = int(input()))
b = int(a /100)
if a > (100b + 10b +b -1):
    print(100(b+1) + 10(b+1) +b +1)
else:
    print(100b + 10b + b)
Problem p03261 (python)

Fixed submission:
N = int(input())
a = []
flag = 1
for i in range(N):
    a.append(str(input()))
    if i != 0:
        for j in range(i):
            if a[i] == a[j]:
                flag =0


back = a[0][-1]
for i in range(1,N):
    front = a[i][0]
    if front != back:
        flag = 0
        break
    back = a[i][-1]

if flag == 0:
    print("No") 
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input().split())
a = []
flag = 1
for i in range(N):
    a.append(str(input().split()))
    if i != 0:
        for j in range(i):
            if a[i] == a[j]:
                flag =0


back = a[0][-1]
for i in range(1,N):
    front = a[i][0]
    if front != back:
        flag = 0
        break
    back = a[i][-1]

if flag == 0:
    print("No") 
else:
    print("Yes")
Problem p03557 (python)

Fixed submission:
#3_1_1
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
c.sort()
ans = 0
for i in range(n):
    ue = bisect.bisect_left(a,b[i])
    sita = n - bisect.bisect_right(c,b[i])
    ans += ue * sita
print(ans)

Buggy submission (verdict: Runtime Error):
#3_1_1
import bisect
n = int(input())
a = list(map(int,input().split))
b = list(map(int,input().split))
c = list(map(int,input().split))

a.sort()
c.sort()
ans = 0
for i in range(n):
    ue = bisect.bisect_left(a,b[i])
    sita = bisect.bisect_right(c,b[i])
    ans += ue * sita
print(ans)
Problem p04001 (python)

Fixed submission:
from itertools import product
S = input()
ans = 0

for string in product(["","+"],repeat=len(S) - 1):
    string = list(string)
    string.append("")
    sum_ = [a + b for a,b in zip(S,string)]
    ans += eval("".join(sum_))

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product
S = input()
ans = 0

for string in product(["","+"],repeat=len(S) - 1):
    string = list(string)
    string.append("")
    sum_ = [a + b for a,b in zip(S,string)]
    ans += sum_

print(ans)
Problem p02921 (python)

Fixed submission:
s=input()
t=input()

cnt=0
for i in range(3):
    if s[i] == t[i]:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):

def MAP():
    return map(int, input().split())

a,b=MAP()

t=1
cnt=0
while True:
    if b <= t:
        break
    t -= 1
    t += a
    cnt += 1
print(cnt)
Problem p02927 (python)

Fixed submission:
M,D=map(int, input().split())

seki=0
for m in range(1,M+1):
    for d in range(1,D+1):
        str_d = str(d)
        if len(str_d)==2:
            d10 = int(str_d[0])
            d1  = int(str_d[1])
            if d10 >= 2 and d1 >= 2 and d10*d1 == m:
                seki+=1
print(seki)

Buggy submission (verdict: Runtime Error):
seki = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        d10, d1 = divmod(d, 10)
        if d10 >= 2 and d1 >= 2 and d10 * d1 == m:
            seki += 1
print(seki)
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def dfs(v, p):
    for next_v in g[v]:
        if next_v == p:
            continue
        cnt[next_v] += cnt[v]
        dfs(next_v, v)


N, Q = map(int, input().split())

g = {i:[] for i in range(N+1)}
cnt = {i:0 for i in range(N+1)}
for _ in range(N - 1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x

dfs(1, -1)

print(*list(cnt.values())[1:])

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

ab=[[] for _ in range(n)]
arr=[0 for _ in range(n)]
cache=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  ab[a-1].append(b-1)

px=[list(map(int,input().split())) for _ in range(q)]
  
  
def search(tree, root):
  arr=[]
  children=tree[root]
  if children == []:
    return None
  else:
    arr.extend(children)
    for child in children:
      ret=search(tree, child)
      if ret is not None:
        arr.extend(ret)    
  return arr


for p,x in px:
  if cache[p-1] == []:
    children=search(ab,p-1)
    if children is not None:
      children=[p-1]+children
    else:
      children=[p-1]
    cache[p-1]=children
    for child in children:
      arr[child]+=x
  else:
    for child in cache[p-1]:
      arr[child]+=x    
print(*arr)

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

ab=[[] for _ in range(n)]
arr=[0 for _ in range(n)]

for _ in range(n-1):
  a,b=map(int,input().split())
  ab[a-1].append(b-1)

px=[list(map(int,input().split())) for _ in range(q)]
  
  
def search(tree, root):
  arr=[]
  children=tree[root]
  if children == []:
    return None
  else:
    arr.extend(children)
    for child in children:
      ret=search(tree, child)
      if ret is not None:
        arr.extend(ret)    
  return arr
      
for p,x in px:
  children=search(ab,p-1)
  if children is not None:
    children=[p-1]+children
  else:
    children=[p-1]
  for child in children:
    arr[child]+=x
print(*arr)
Problem p02994 (python)

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

x=[l+i-1 for i in range(1,n+1)]
min_val=None
idx=0
for i in range(1,n+1):
  tmp=abs(l+i-1)
  if min_val is None or tmp < min_val:
    min_val=tmp
    idx=i-1

x.pop(idx)
print(sum(x))

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

x=[l+i-1 for i in range(1,n+1)]

min_val=None
idx=0
for i in x:
  if min_val is None or abs(l+i-1) < min_val:
    min_val=abs(l+i-1)
    idx=i-1

x.pop(idx)
print(sum(x))
Problem p03086 (python)

Fixed submission:
s=input()

cnt=0
max_val=0
for s_ in s:
  if s_ in ('A', 'C', 'G', 'T'):
    cnt+=1
  else:
    cnt=0
  max_val=max(cnt, max_val)
print(max_val)

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

arr=[]
tmp=''
for s_ in s:
  if s_ in ('A', 'C', 'G', 'T'):
    tmp+=s_
  else:
    arr.append(len(tmp))
    tmp=''
print(max(arr))
Problem p03160 (python)

Fixed submission:
INF = float('inf')

def LIST():
    return list(map(int, input().split()))

N=int(input())
h=LIST()

# DP配列を初期化
dp=[INF] * N

# 初期条件を入力
dp[0]=0

# テーブルを更新 もらうDP
for i in range(1,N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i >= 2:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Buggy submission (verdict: Runtime Error):
INF = float('inf')


def LIST():
    return list(map(int, input().split()))


def rec(i: int):
    if dp[i] < INF:
        return dp[i]

    if i == 0:
        return 0

    res = INF
    res = min(res, rec(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = min(res, rec(i - 2) + abs(h[i] - h[i - 2]))

    dp[i] = res

    return dp[i]


N = int(input())
h = LIST()

h.extend([0] * 2)

dp = [INF] * (N + 2)

print(rec(N - 1))
Problem p03161 (python)

Fixed submission:
import sys

INF = float('inf')

input = sys.stdin.readline


def LIST():
    return list(map(int, input().split()))


N, K = LIST()
h = LIST()

# DP配列を初期化
dp = [INF] * N

# 初期条件を入力
dp[0] = 0

# テーブルを更新 もらうDP
for i in range(1, N):
    x = max(0, i - K)
    dp[i] = min([dp_ + abs(h[i] - h_) for dp_, h_ in zip(dp[x:i], h[x:i])])

print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
INF = float('inf')

input = sys.stdin.readline


def LIST():
    return list(map(int, input().split()))


N, K = LIST()
h = LIST()

h.extend([0] * K)

# DP配列を初期化
dp = [INF] * (N + K)

# 初期条件を入力
dp[0] = 0

# テーブルを更新 くばるDP
for i in range(0, N):
    for j in range(1, K + 1):
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))

print(dp[N - 1])
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())

ans = N % 500
if max(ans - A, 0):
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s = int(input()) - int(input())
if s < 0:
  print('No')
else:
  if s % 500 == 0:
	print('Yes')
  else:
    print('No')
Problem p03693 (python)

Fixed submission:
r,g,b = map(int, input().split())
total = r*100+g*10+b
if total % 4 == 0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
r,g,b = map(int, input().split())
if b & 3:
  print('NO')
else:
  printt('YES')
Problem p04029 (python)

Fixed submission:
n=int(input())
cnt=0
for x in range(1,n+1):
  cnt+=x
print(cnt)

Buggy submission (verdict: Runtime Error):
print((int(input())+1)*n//2)
Problem p04044 (python)

Fixed submission:
N,L,*s = open(0).read().split()
print("".join(sorted(s)))

Buggy submission (verdict: Runtime Error):
import itertools
N,L,*s = open(0).read().split()
x = list(map(lambda x:"".join(x), itertools.permutations(s, int(N))))
min_str = x[0]
for s in x[1:]:
  if s < min_str:
    min_str = s
print(min_str)
Problem p02772 (python)

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

a_even = []
for ai in a:
    if ai%2 == 0:
        a_even += [ai]

ans = "APPROVED"
for a_eveni in a_even:
    if a_eveni%3 != 0 and a_eveni%5 != 0:
        ans = "DENIED"
        break

print(ans)

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

n = int(input())
a = np.array([int(x) for x in input().split()])

a1 = list(map(lambda x: bool(x/2%1), a))
a2 = list(map(lambda x: bool(x/3%1), a/2))
a3 = list(map(lambda x: bool(x/5%1), a/2))
a4 = list(map(lambda x, y: x and y, a2, a3))
if a1.count(False) == a4.count(False):
    print("APPROVED")
else:
    print("DENIED"

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

a_even = []
for ai in a:
    if ai%2 == 0:
        a_even += [ai]

for a_eveni in a_even:
    if a_eveni%3 != 0 or a_eveni%5 != 0:
        ans = "DENIED"
    else:
        ans = "APPROVED"
print(ans)
Problem p02952 (python)

Fixed submission:
n = input()

sm = 0
if int(n) <= 9:
    sm = n
elif len(n)%2 != 0:
    for i in range(0, len(n)-1, 2):
        sm += 9*10**i
    sm += int(n)-10**int(len(n)-1)+1
else:
    for i in range(0, len(n)-1, 2):
        sm += 9*10**i
        
print(sm)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
print(" ".join([b, a]))

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

sm = 0
if len(n)%2 != 0:
    for i in range(0, len(n)-2, 2):
        sm += 9*10**i
    sm += int(n[1:])+1
else:
    for i in range(0, len(n)-1, 2):
        sm += 9*10**i
        
print(sm)
Problem p03035 (python)

Fixed submission:
a,b=[int(x) for x in input().split()]
if a>=13:
    print(b)
elif 6<=a<=12:
    print(int(b/2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b=[x for x in input().split()]
if a>=13:
    print(b)
elif 6<=a<=12:
    print(b/2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b=[x for x in input().split()]
if a>=13:
    print(b)
elseif 6<=a<=12:
    print(b/2)
else:
    print(0)
Problem p03076 (python)

Fixed submission:
import numpy as np

a = np.array([int(input()) for _ in range(5)])
aa = np.array(list(map(lambda x: -(-x//10*10), a)))
b = aa-a
ans = sum(aa)-max(b)
print(ans)

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

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

M = np.array([a, b, c, d, e])
t = np.array(list(map(lambda x: x%10, M)))
tt = min(t[t != 0])

if len(M[t == tt]) != 1:
    MS = sorted(M)
    MM = [MS[0]]
    MMM = MS[1:]
else:
    MM = M[t == tt]
    MMM = M[t != tt]

s = np.array(list(map(lambda x: -(-x//10*10), MMM)))

wk = np.concatenate([MM, s])
ans = sum(wk)
print(ans)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

arr = [A, B, C, D, E]
arr_s = sorted(set(list(map(lambda x: x%10, arr))))
if arr_s[0] == 0:
    mn = arr_s[1]
else:
    mn = arr_s[0]

b = 0
for a in arr:
    b += (a//10)*10
    if a%10 != 0:
        b += 10
ans = b - 10 + mn
print(ans)
Problem p03109 (python)

Fixed submission:
S = input()
wk = int(S[:4]+S[5:7]+S[8:10])
if wk<=20190430:
    print("Heisei")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
S = input()
wk = S[:4]+S[5:7]+S[8:10]
if wk=<20190430:
    print("Heisei")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
S = input()
wk = S[:4]+S[5:7]+S[8:10]
if wk<20190430:
    print("Heisei")
else:
    print("TBD")
Problem p03210 (python)

Fixed submission:
X = int(input())
wk = (X-7)*(X-5)*(X-3)
if wk == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
X = int(input())
if X = 7 or 5 or 3:
    print("YES")
else:
    print("NO")
Problem p03238 (python)

Fixed submission:
N = int(input())
if N==1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N==1:
    print("Hello World")
else:
    A, B = [int(x) for x in input().split()]
    print(int(A+B))

Buggy submission (verdict: Runtime Error):
N = int(input())
if N==1:
    print("Hello World")
else:
    A, B = [int(x) for x in input().split()]
    print(A+B)
Problem p03239 (python)

Fixed submission:
n ,t = [int(x) for x in input().split()]
arr = [list(map(int, input().split())) for _ in range(n)]

ans = 9999
for i in range(n):
    if arr[i][1] <= t:
        if arr[i][0] <= ans:
            ans = arr[i][0]
if ans == 9999:
    print("TLE")
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n ,t = [int(x) for x in input().split()]
arr = [list(map(int, input().split())) for _ in range(n)]

ans = 9999
for i in range(n):
    if arr[i][1] <= t:
        if arr[i][0] <= ans:
            ans = arr[i][0]
if ans = 9999:
    print("TLE")
else:
    print(ans)
Problem p03399 (python)

Fixed submission:
wk = [int(input()) for i in range(4)]
print(min(wk[0], wk[1])+min(wk[2], wk[3]))

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

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int, input().split())
print(min([a,b])+min([c,d]))
Problem p03423 (python)

Fixed submission:
n = int(input())
print(n//3)

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

if "Y" in s:
    print("Four")
else:
    print("Three")
Problem p03433 (python)

Fixed submission:
n = int(input())
a = int(input())

if a>=(n%500):
    print("Yes")
else:
    print("No")

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

if a<=(n%500):
    print("Yes")
else:
    prit("No")
Problem p03494 (python)

Fixed submission:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])

cnt = 0
while sum(a%2) == 0:
    cnt += 1
    a = a//2
print(cnt)

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

n = int(input())
a = [int(x) for x in input().split()]

cnt = 0
while sum(a%2) == 0:
    cnt += 1
    a = a//2
print(cnt)

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

n = int(input())
a = [int(input()) for _ in range(n)]

cnt = 0
while sum(a%2) == 0:
    cnt += 1
    a = a//2
print(cnt)
Problem p03543 (python)

Fixed submission:
n = input()
if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n0, n1, n2, n3 = int(input())
if n0==n1==n2 or n1==n2==n3:
    print("Yes")
else:
    print("No")
Problem p03544 (python)

Fixed submission:
n = int(input())
a = 2
b = 1

if n==1:
    print(b)
else:
    for i in range(n-1):
        c = a+b
        temp = b
        b = c
        a = temp
    print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 2
b = 1

for i in range(n-1):
    c = a+b
    temp = b
    b = c
    a = temp

print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 2
b = 1

for i in range(n-1):
    c = a+b
    temp = b
    b = c
    a = temp

print(c)
Problem p03555 (python)

Fixed submission:
c0 = input()
c1 = input()

if c0[0]==c1[2] and c0[1]==c1[1] and c0[2]==c1[0]:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
c11, c12, c13 = input().split()
c21, c22, c23 = input().split()

if c11==c23 and c12==c22 and c13==c21:
    print("YES")
else:
    print("NO")
Problem p03657 (python)

Fixed submission:
a, b = map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%==0:
    print("Possible")
else:
    print("Impossible")
Problem p03712 (python)

Fixed submission:
h, w = map(int, input().split())
a = [input().split() for _ in range(h)]

print("#"*(w+2))
for i in range(h):
    t = "".join(["#"]+a[i]+["#"])
    print(t)
print("#"*(w+2))

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [input().split() for _ in range(2)]

print("#"*(w+2))
for i in range(h):
    t = "".join(["#"]+a[i]+["#"])
    print(t)
print("#"*(w+2))
Problem p03729 (python)

Fixed submission:
s = input().split()
if s[0][-1]==s[1][0] and s[1][-1]==s[2][0]:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s = input().split()
print(s)
if s[0][-1]==s[1][0] and s[1][-1]==s[2][1]:
    print("YES")
else:
    print("NO")
Problem p03844 (python)

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

if op == "+":
    ans = a+b
else:
    ans = a-b
print(ans)

Buggy submission (verdict: Runtime Error):
a, op, b = [input().split()]
eval(a+op+b)
Problem p03860 (python)

Fixed submission:
wk = input().split()
print("A"+wk[1][0]+"C")

Buggy submission (verdict: Runtime Error):
wk = input().split()
print(A+wk[1][0]+C)
Problem p03962 (python)

Fixed submission:
import collections

p = [int(x) for x in input().split()]
c = collections.Counter(p)
print(len(c))

Buggy submission (verdict: Runtime Error):
p = [int(x) for x in input().split()]
print(p.unique().count())
Problem p02945 (python)

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

print(max(a+b,a-b,a*b))

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

print(max(a+b, a-b, a * b))
Problem p02995 (python)

Fixed submission:
def gcd(a,b):
    if a < b:
        a, b = b, a
    while  a % b != 0:
        a, b = b, a % b
    return b

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

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())
res = 0
lcm = c*d // math.gcd(c,d)
divisible = (b//c) - ((a-1)//c) + (b//d) - ((a-1)//d) - (b//lcm) - ((a-1)//lcm)
res = b-a+1 - divisible
print(res)
Problem p03160 (python)

Fixed submission:
def main():
	n = int(input())
	costs = list(map(int, input().split()))
	
	if n==1: return 0
	# each cur represents minimum cost needed to reach the step
	two_before = 0
	one_before = abs(costs[1] - costs[0])
	for step in range(2, n):
		two_before, one_before = one_before, min(one_before + abs(costs[step] - costs[step-1]), two_before + abs(costs[step] - costs[step - 2]))
	return one_before


print(main())

Buggy submission (verdict: Runtime Error):
from math import abs
def main():
	n = int(input())
	costs = list(map(int, input().split()))
	
	# each cur represents minimum cost needed to reach the step
	two_before = 0
	one_before = costs[1] - costs[0]
	for step in range(2, n):
		two_before, one_before = one_before, min(one_before + abs(costs[step] - costs[step-1]), two_before + abs(costs[step] - costs[step - 2]))
	return one_before
main()
Problem p02706 (python)

Fixed submission:
n,m=map(int,input().split())
list1=list(map(int,input().split()))
ans=n-sum(list1)
print(ans if ans>=0 else -1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
hw_days=0
for i in range(m):
  hw_days+=int(input())
print(n-hw_days if (n-hw_days)>0 else -1)
Problem p02921 (python)

Fixed submission:
s=input()
t=input()
ans=0
for i in range(3):
  if s[i]==t[i]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans=0
answer=[]
for i in range(n-1):
  if h[i]>=h[i+1]:
    ans+=1
  if h[i]<h[i+1]:
    answer.append(ans)
    ans=0
  if i == n-2:
    answer.append(ans)
  else:
    pass
print(max(answer))