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

Fixed submission:
O = list(input())
E = list(input())
ans = list()
LEN = len(O)+len(E)
for i in range(LEN):
    if i%2==0:
        ans.append(O[0])
        del O[0]
    else:
        ans.append(E[0])
        del E[0]
result = "".join(ans)
print(result)

Buggy submission (verdict: Runtime Error):
O = list(input())
E = list(input())
ans = list()
 
for i in range(len(O)):
    ans.append(O[i])
    if i > len(E):
        break
    else:
        ans.append(E[i])
result = "".join(ans)
print(result)

Buggy submission (verdict: Runtime Error):
O = list(input())
E = list(input())
ans = list()
 
for i in range(len(O)):
    ans.append(O[i])
    if not E[i]:
        break
    else:
        ans.append(E[i])
result = "".join(ans)
print(result)

Buggy submission (verdict: Runtime Error):
O = list(input())
E = list(input())
ans = list()

for i in range(len(O)):
    ans.append(O[i])
    ans.append(E[i])
result = "".join(ans)
print(result)
Problem p02607 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N):
  if i % 2 == 0 and A[i] % 2 == 1:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N):
	if i % 2 == 0 and A[i] % 2 == 1:
    	count += 1
print(count)
Problem p02608 (python)

Fixed submission:
import math
N = int(input())
fn_array = [0] * 60000
for x in range(1, 100):
    for y in range(1, x + 1):
        for z in range(1, y + 1):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if x == y and y == z:
                fn_array[n] += 1
            elif (x == y) and (y != z):
                fn_array[n] += 3
            elif (x != y) and (y == z):
                fn_array[n] += 3
            else:
                fn_array[n] += 6
for n in range(1, N+1):
    print(fn_array[n])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
rootN = math.sqrt(N)
rootN = math.floor(rootN)
maxN = 1001
fn_array = [0] * 1000
for x in range(1, rootN):
    for y in range(1, x + 1):
        for z in range(1, y + 1):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if x == y and y == z:
                fn_array[n] += 1
            elif (x == y) and (y != z):
                fn_array[n] += 3
            elif (x != y) and (y == z):
                fn_array[n] += 3
            else:
                fn_array[n] += 6
for n in range(1, N+1):
    print(fn_array[n])
Problem p02614 (python)

Fixed submission:
a = input().rstrip().split(" ")
 
H = int(a[0])   #行
W = int(a[1])   #列
K = int(a[2])   #操作後に残る黒いマスの数
 
m = []
for i in range(H):
    n = list(input())
    m.append(n)
 
#print(m)
ans = 0
 
#2進数のyes/no(赤く塗るか否か)列を作る
for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskC >> j & 1) == 0 and m[i][j] == "#":
                    black += 1
    
        if black == K:
            ans += 1
 
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

a = input().rstrip().split(" ")

H = int(a[0])  # 行
W = int(a[1])  # 列
K = int(a[2])  # 操作後に残る黒いマスの数

m = []
for i in range(H):
    n = list(input())
    m.append(n)

# print(m)
ans = 0

for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskL >> j & 1) == 0 and m[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

a = input().rstrip().split(" ")

H = int(a[0])  # 行
W = int(a[1])  # 列
K = int(a[2])  # 操作後に残る黒いマスの数

m = []
for i in range(H):
    n = list(input())
    m.append(n)

# print(m)
ans = 0

for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskL >> j & 1) == 0 and m[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 3 2
..#
###"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3 4
..#
###"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2 2 3
##
##"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """6 6 8
..##..
.#..#.
#....#
######
#....#
#....#"""
        output = """208"""
        self.assertIO(input, output)


if __name__ == "__main__":
    unittest.main()
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a*b) % 2:
  print('Odd')
  else:
    print('Even')

Buggy submission (verdict: Runtime Error):
    a, b = map(int, input().split())
    if (a*b) % 2:
        print('Odd')
    else:
        print('Even')
Problem p03493 (python)

Fixed submission:
s = input()
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
    s = input()
    print(s.count('1'))
Problem p03545 (python)

Fixed submission:
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き

    formula = ""
    for p_n, p_o in zip(n, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Buggy submission (verdict: Runtime Error):
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2**op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if (i >> j) & 1:
      op[op_cnt-1-j] = '+'
      formula = ''
      for p_n, p_o in zip(n, op + ['']):
        formula += (p_n + p_o)
        if eval(formula) == 7:
          print(formula + '=7')
          break

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest


n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2**op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if (i >> j) & 1:
      op[op_cnt-1-j] = '+'
      formula = ''
      for p_n, p_o in zip(n, op + ['']):
        formula += (p_n + p_o)
        if eval(formula) == 7:
          print(formula + '=7')
          break
Problem p02658 (python)

Fixed submission:

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

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
    return

main ()

Buggy submission (verdict: Runtime Error):

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

    if 0 in A:
        print(0)

    prod = 1
    for a in A:
        prod *= a
        if prod > 10**18:
            print(-1)

    print(prod)

Buggy submission (verdict: Runtime Error):
def main ():
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    return

prod = 1
for a in A:
    prod *= a
    if prod > 1000000000000000000:
        print(-1)
        return

    print(prod)
main ()

Buggy submission (verdict: Runtime Error):

n=int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)

prod = 1
for a in A:
    prod *= a
    if prod > 10**18:
        print(-1)

print(prod)

Buggy submission (verdict: Runtime Error):

n=int(input())
a = list(map(int,input(). split ()))
if 0 in a:
    print(0)

prod = 1
for a in A:
    prod *= a
    if prod > 10**18:
        print(-1)

print(prod)

Buggy submission (verdict: Runtime Error):

n=int(input())
a = list(map(int,input(). split ()))
if 0 in a:
    print(0)
    return

prod = 1
for a in A:
    prod *= a
    if prod > 10**18:
        print(-1)
        return

print(prod)

Buggy submission (verdict: Runtime Error):

n,*a=map(int,input().split)

val=1
for x in a:
    val*=x

print(val if val<=10**18 else '-1')
Problem p02696 (python)

Fixed submission:
a, b, n = list(map(int, input().split()))
x = min(b - 1, n) # b-1がいいけど、上限 nの制約あり
ans = int(a * x / b)
print(ans)

Buggy submission (verdict: Runtime Error):

import numpy as np
import math
a,b,n=map(int,input().split())

x=np.arange(1,math.log10(n),0.01)
s1=np.floor(a*x*10**math.log10(n)/b)
s2=a*np.floor(x*10**math.log10(n)/b)
s=s1-s2

if n<b:s=np.array(math.floor(a*n/b)-a*math.floor(n/b))
print(int(np.max(s)))

Buggy submission (verdict: Runtime Error):

import numpy as np
a,b,n=map(int,input().split())

x=np.arange(1,n+1)

s1=np.floor(a*x/b)
s2=a*np.floor(x/b)
s=s1-s2
print(int(np.max(s)))

Buggy submission (verdict: Runtime Error):

import numpy as np
a,b,n=map(int,input().split())

x=np.arange(1,n+1)

s1=np.floor(a*x/b)
s2=a*np.floor(x/b)
s=s1-s2
print(int(np.max(s)))

Buggy submission (verdict: Runtime Error):

import numpy as np
a,b,n=map(int,input().split())

x=np.arange(1,n+1)

s1=np.floor((a/b)*x)
s2=a*np.floor(x/b)
s=s1-s2
print(int(np.max(s)))

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b,n=map(int,input().split())

x=np.arange(1,n+1)

s1=np.floor((a/b)*x)
s2=a*np.floor(x/b)
s=s1-s2
print(np.max(s))
Problem p02702 (python)

Fixed submission:
s=list(input())[::-1] # 10進数で位を上げていくために反転させる
n=len(s)
amari_lis=[0]*2019 # 
amari_lis[0]=1 # 2019で割り切れる場合、組合せ総数は (n+1)C2 となるため（その他はnC2でOK）

num=0
kurai=1
for keta in s:
    num+=int(keta)*kurai
    num%=2019
    amari_lis[num]+=1
    kurai*=10
    kurai%=2019 # amari_lisが 0~2019 のため、位の数も 2019 で割った余りで考える

ans=0
for i in amari_lis:
    ans+=i*(i-1)/2 # nC2の計算, 余りが同じものを引けば 0⇒2019で割れると言える（組合せ数を逐次追加することで総数算出）

print(int(ans))

Buggy submission (verdict: Runtime Error):

S = str(input())

amari = []
for i in range(len(S)+1):
    for j in range(i+4, len(S)+1):
        amari_tmp = int(S[i:j]) % 2019
        amari.append(amari_tmp)
        kosu = amari.count(0)

print(kosu)

Buggy submission (verdict: Runtime Error):

S = str(input())

amari = []
for i in range(len(S)+1):
    for j in range(i+4, len(S)+1):
        amari_tmp = int(S[i:j]) % 2019
        amari.append(amari_tmp)
        kosu = amari.count(0)

print(kosu)
Problem p02719 (python)

Fixed submission:

N, K = map(int, input().split())
amari=N%K

print(min(amari,abs(amari-K)))

Buggy submission (verdict: Runtime Error):

N, K = map(int, input().split())
amari%=K

print(min(amari,abs(amari-k)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
amari%=K

print(amari,abs(amari-k))

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

if K == 1:
    print(0)

else:
    shou, amari_1 = divmod(N, abs(N-K))
    N_min_1 = N - (shou * abs(N-K))
    N_min_2 = abs(N_min_1 - abs(N-K))
    print(min(N_min_1, N_min_2))

Buggy submission (verdict: Runtime Error):

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

if K == 1:
    print(0)

else:
    shou, amari_1 = divmod(N, abs(N-K))
    N_min_1 = N - (shou * abs(N-K))
    N_min_2 = abs(N_min_1 - abs(N-K))
    print(min(N_min_1, N_min_2))

Buggy submission (verdict: Runtime Error):

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

if K == 1:
    print(0)

else:
    shou, N_min_1 = divmod(N, abs(N-K))
    N_min_2 = abs(N_min_1 - abs(N-K))
    print(min(N_min_1, N_min_2))

Buggy submission (verdict: Runtime Error):

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

shou, N_min_1 = divmod(N, abs(N-K))
N_min_2 = abs(N_min_1 - abs(N-K))
print(min(N_min_1, N_min_2))

Buggy submission (verdict: Runtime Error):

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

shou, N_min = divmod(N, abs(N-K))
print(N_min)
Problem p02742 (python)

Fixed submission:

H, W = map(int, input().split())

if (H == 1 or W == 1):
    print(1)
    
elif (H * W) % 2 == 0:
    print(int((H * W) / 2))

else:
    masu = int((H * W) / 2) + 1
    print(masu)

Buggy submission (verdict: Runtime Error):

H, W = map(int, input().split())

if (H = 1 or W = 1):
    print(1)
    
elif (H * W) % 2 == 0:
    print(int((H * W) / 2))

else:
    masu = int((H * W) / 2) + 1
    print(masu)
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = []
s.append(min(a) + min(b))

for i in range(M):
    x_i, y_i, c_i = map(int, input().split())
    minus = a[x_i - 1] + b[y_i - 1] - c_i
    s.append(minus)

print(min(s))

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = []
s.append(min(a) + min(b))

for i in range(M):
    x_i, y_i, c_i = map(int, input().split())
    minus = a[x_i - 1] + a[y_i - 1] - c_i
    s.append(minus)

print(min(s))

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = []
for a_i in a:
    for b_i in b:
        sum_ab = a_i + b_i
        s.append(sum_ab)

for i in range(M):
    x_i, y_i, c_i = map(int, input().split())
    minus = a[x_i - 1] + a[y_i - 1] - c_i
    s.append(minus)

print(min(s))
Problem p02755 (python)

Fixed submission:
import numpy as np
import math
A, B = map(int, input().split())

x_a = np.arange(math.ceil(12.5 * A), math.ceil(12.5 * (A + 1)))
x_b = np.arange(10 * B, 10 * (B + 1))

a_set = set(x_a)
b_set = set(x_b)
#aとbに共通するものを抽出
c_set = a_set & b_set
c = list(c_set)

if len(c) != 0:
    print(min(c))

else:
    print("-1")

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
A, B = map(int, input().split())

x_a = np.arange(math.ceil(12.5 * A), math.ceil(12.5 * (A + 1)))
x_b = np.arange(10 * B, 10 * (B + 1))

a_set = set(x_a)
b_set = set(x_b)
#aとbに共通するものを抽出
c_set = a_set & b_set
c = list(c_set)
x = min(c)
print(x)

if not c:
    print("-1")

else:
    continue

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
A, B = map(int, input().split())

x_a = np.arange(math.ceil(12.5 * A), math.ceil(12.5 * (A + 1)))
x_b = np.arange(10 * B, 10 * (B + 1))

a_set = set(x_a)
b_set = set(x_b)
c_set = a_set & b_set
c = list(c_set)
x = min(c)
print(x)

if not c:
    print("-1")
Problem p02765 (python)

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

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

if N >= 10:
  print(str(R))
  
 else:
  print(str(R + 100 * (10 - N)))
Problem p02909 (python)

Fixed submission:

s=input()
if s=="Sunny":
    print("Cloudy")
elif s=="Cloudy":
    print("Rainy")
else:
    print("Sunny")

Buggy submission (verdict: Runtime Error):

n=int(input())
print(n**3)
Problem p02923 (python)

Fixed submission:

n=int(input())
h=list(map(int,input().split()))

score = [0]*n
for i in range(n-2,-1,-1):
    if h[i] >= h[i+1]:
        score[i] = score[i+1] + 1
 
print(max(score))

Buggy submission (verdict: Runtime Error):

n=int(input())
h=list(map(int,input().split()))

score = [0]*n
for i in range(n-2,-1,-1):
    if H[i] >= H[i+1]:
        score[i] = score[i+1] + 1
 
print(max(score))
Problem p02934 (python)

Fixed submission:

import numpy as np
n=int(input())
a=list(map(float,input().split()))
a_array=np.array(a)
a_inv=np.reciprocal(a_array)
print(float(1/sum(a_inv)))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=np.array(list(map(float,input().split())))
print(float(1/sum(1/a_array)))
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().spllit())
print(max(a+b,a-b,a*b))
Problem p02988 (python)

Fixed submission:

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n-1):
    if (p[i-1]<p[i] and p[i]<p[i+1]) or (p[i-1]>p[i] and p[i]>p[i+1]):
        count+=1
    else:
        continue
print(count)

Buggy submission (verdict: Runtime Error):

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        count+=1
for i in range(1,n-1):     
    if p[i-1]>p[i] and p[i]>p[i+1]:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        count+=1
for i in range(1,n-1):     
    if p[i-1]>p[i] and p[i]>p[i+1]:
        count+=1
print(count)
Problem p02994 (python)

Fixed submission:

n,l=map(int,input().split())
aji_lis=[int(l+i-1) for i in range(1,n+1)]

N_sum=sum(aji_lis)
ap=min([abs(i) for i in aji_lis])

if N_sum >=0:
    print(N_sum-ap)
else:
    print(N_sum+ap)

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import jit#import numbaで関数前で@numba.jitでもok
@jit
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import jit#import numbaで関数前で@numba.jitでもok
@jit
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Buggy submission (verdict: Runtime Error):
import numpy as np
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Buggy submission (verdict: Runtime Error):
import numpy as np
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Buggy submission (verdict: Runtime Error):
import numpy as np
a = np.arange(L, L + N)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])
Problem p02995 (python)

Fixed submission:


import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

# dとAの行が交互に並んでいる場合
s = sys.stdin.readlines()
n, k=map(int, s[0].split())
d=[]
A=[]
for i in s[1:2*k:2]:
    d.append(int(i))
for i in s[2:2*k+1:2]:
    A.append(list(map(int, i.split())))
"""

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

import fractions
f = fractions.gcd(c,d) # 最大公約数
f2 = c*d // f # 最小公倍数

# b以下で条件を満たす個数
shou1=b//c
shou2=b//d
shou3=b//f2
num_b=b-(shou1+shou2-shou3)

# a-1以下で条件を満たす個数
shou4=(a-1)//c
shou5=(a-1)//d
shou6=(a-1)//f2
num_a=(a-1)-(shou4+shou5-shou6)

print(num_b-num_a)

Buggy submission (verdict: Runtime Error):


import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

# dとAの行が交互に並んでいる場合
s = sys.stdin.readlines()
n, k=map(int, s[0].split())
d=[]
A=[]
for i in s[1:2*k:2]:
    d.append(int(i))
for i in s[2:2*k+1:2]:
    A.append(list(map(int, i.split())))
"""

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

import math
f = math.gcd(a,b) # 最大公約数
f2 = a*b // f # 最小公倍数

# b以下で条件を満たす個数
shou1=b//c
shou2=b//d
shou3=b//f2
num_b=b-(shou1+shou2-shou3)

# a-1以下で条件を満たす個数
shou4=(a-1)//c
shou5=(a-1)//d
shou6=(a-1)//f2
num_a=(a-1)-(shou4+shou5-shou6)

print(num_b-num_a)
Problem p03031 (python)

Fixed submission:

# 解答（@maspy）

# switchが10個以下
N,M = map(int,input().split())
sw = [[] for _ in range(M)]
# print(sw) # [[], [], ..., []]

for i in range(M):
    sw[i] = list(map(int,input().split()[1:]))
# print(sw) # [[１行目], [２行目], ..., [M行目]]

p = [int(x) for x in input().split()]
import itertools

answer = 0
for tpl in itertools.product([0,1],repeat=N):
  bl = True
  for i in range(M):
    # 電球iを計算
    s = sum([tpl[s-1] for s in sw[i]])
    if (s-p[i])%2 != 0:
      bl = False
      break
  if bl:
    answer += 1
print(answer)

Buggy submission (verdict: Runtime Error):

# 解答（@maspy）

# switchが10個以下
N,M = map(int,input().split())
sw = [[] for _ in range(M)]
# print(sw) # [[], [], ..., []]

for i in range(M):
    sw[i] = list(map(int,input().split()[1:]))
# print(sw) # [[１行目], [２行目], ..., [M行目]]

import itertools

answer = 0
for tpl in itertools.product([0,1],repeat=N):
  bl = True
  for i in range(M):
    # 電球iを計算
    s = sum([tpl[s-1] for s in sw[i]])
    if (s-p[i])%2 != 0:
      bl = False
      break
  if bl:
    answer += 1
print(answer)
Problem p03037 (python)

Fixed submission:

# 左右の範囲を絞っていくことで共通要素のみを炙り出す
n,m = map(int,input().split())
l = -1
r = n+1
for i in range(m):
    l_i,r_i = map(int,input().split())
    l = max(l,l_i)
    r = min(r,r_i)
print(max(0,r-l+1))

Buggy submission (verdict: Runtime Error):

n,m = map(int,input().split())
s = -1
t = n+1
for i in range(m):
    l_i,r_i = map(int,input().split())
    l = max(l,l_i)
    r = min(r,r_i)
print(max(0,r-l+1))
Problem p03999 (python)

Fixed submission:
s = input()
n = len(s)

def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    # 関数の足し算はメソッドを記憶したまま、各関数に分岐していく
    # → (2:返る関数が2個) ^ (n-1:再帰回数が i=0,1...でn-1回) ＝ 最終的な関数は2^(n-1)個
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))

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


def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

	return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))

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

start = time.time()

def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))
Problem p02760 (python)

Fixed submission:
a=[list(map(int,input().split()))for _ in range(3)]
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans='No'
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0:
        ans='Yes'
    if a[0][i]==a[1][i]==a[2][i]==0:
        ans='Yes'
if a[0][0]==a[1][1]==a[2][2]==0:
    ans='Yes'
if a[2][0]==a[1][1]==a[0][2]==0:
    ans='Yes'
print(ans)
Problem p02783 (python)

Fixed submission:
h,a = map(int,input().split())
if h % a == 0:
    print(h//a)
else:
    print(h//a + 1)

Buggy submission (verdict: Runtime Error):
h = int(input())
a = int(input())
if h % a == 0:
    print(h//a)
else:
    print(h//a + 1)