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

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = list(input())
    reslut = []
    for s in S:
        if s == 'B' and len(reslut) == 0:
            continue
        elif s == 'B':
            reslut.pop()
        else:
            reslut.append(s)
    print(''.join(reslut))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = list(input().split())
    reslut = ''
    for s in S:
        if S == 'B':
            reslut.pop()
        else:
            reslut.append(s)
    print(reslut)


if __name__ == "__main__":
    main()
Problem p04045 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

    while True:
        if all([True if n not in D else False for n in list(str(N))]):
            break
        N += 1
    print(N)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    D = set(list(map(int, input().split())))
    F = set(list(range(10))) - D
    result = ''
    for n in str(N):
        if int(n) in F:
            result += n
        else:
            result += str(min([f for f in F if f > int(n)]))
    print(result)


if __name__ == "__main__":
    main()
Problem p03035 (python)

Fixed submission:
value = input().split()
age = int(value[0])
cost = int(value[1])

if(age >= 6 and age<= 12):
    cost = cost // 2
elif(age <= 5):
    cost = 0

print(cost)

Buggy submission (verdict: Runtime Error):
value = input().split()
age = int(value[0])
cost = int(value[1])

if(age >= 6 and age<= 12):
    result = cost // 2
elif(age <= 5):
    result = 0

print(result)
Problem p03076 (python)

Fixed submission:
order_time = [0, 0, 0, 0, 0]
order = len(order_time)
time = 0
last_order = 9
count_change = 0

for i in range(0, order):
    order_time[i] = int(input())
    if (order_time[i] % 10 != 0) and (order_time[i] % 10 <= last_order % 10):
        last_order = order_time[i]
        count_change += 1

for i in range(0, order):
    if order_time[i] % 10 != 0:
        time += order_time[i] // 10 * 10 + 10
    else:
        time += order_time[i]

if count_change == 0:
    last_order = 0
else:
    time -= last_order // 10 * 10 + 10
    time += last_order

print(time)

Buggy submission (verdict: Runtime Error):
order_time = [0, 0, 0, 0, 0]
order = len(order_time)
time = 0
last_order = 9
count_change = 0

for i in range(0, order):
    order_time[i] = int(input())
    if (order_time[i] % 10 != 0) and (order_time[i] % 10 <= last_order % 10):
        last_order = order_time[i]
        count_change += 1

if count_change == 0:
    last_order = order_time[i]

for i in range(0, order):
    if order_time[i] % 10 != 0:
        time += order_time[i] // 10 * 10 + 10
    else:
        time += order_time[i]

time -= last_order // 10 * 10 + 10
time += last_order

print(time)
order_time = [0, 0, 0, 0, 0]
order = len(order_time)
time = 0
last_order = 9
count_change = 0

for i in range(0, order):
    order_time[i] = int(input())
    if (order_time[i] % 10 != 0) and (order_time[i] % 10 <= last_order % 10):
        last_order = order_time[i]
        count_change += 1

for i in range(0, order):
    if order_time[i] % 10 != 0:
        time += order_time[i] // 10 * 10 + 10
    else:
        time += order_time[i]

if count_change == 0:
    last_order = order_time[i]
else:
    time -= last_order // 10 * 10 + 10
    time += last_order

print(time)
Problem p03487 (python)

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

a.sort()
cnt = 1
ans = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        cnt += 1
        continue

    if cnt >= a[i]:
        ans += cnt - a[i]
    else:
        ans += cnt
    cnt = 1
if cnt >= a[-1]:
    ans += cnt - a[-1]
else:
    ans += cnt
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
max = max(a) + 1
num = [0] * max
for i in a:
    num[i] += 1
ans = 0
for i in range(max):
    if i > num[i]:
        ans += num[i]
    else:
        ans += num[i] - i
print(ans)
Problem p03544 (python)

Fixed submission:
n = int(input())
l = [2, 1]
for i in range(n-1):
    l.append(l[i] + l[i+1])
print(l[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
f = 2
s = 1
for i in range(n-1):
    l = f + s
    f = s
    s = l
print(l)
Problem p03545 (python)

Fixed submission:
a, b, c, d = map(int, input())

if a + b + c + d == 7:
    print(a, '+', b, '+', c, '+', d, '=', 7, sep='')
elif a + b + c - d == 7:
    print(a, '+', b, '+', c, '-', d, '=', 7, sep='')
elif a + b - c + d == 7:
    print(a, '+', b, '-', c, '+', d, '=', 7, sep='')
elif a + b - c - d == 7:
    print(a, '+', b, '-', c, '-', d, '=', 7, sep='')
elif a - b + c + d == 7:
    print(a, '-', b, '+', c, '+', d, '=', 7, sep='')
elif a - b + c - d == 7:
    print(a, '-', b, '+', c, '-', d, '=', 7, sep='')
elif a - b - c + d == 7:
    print(a, '-', b, '-', c, '+', d, '=', 7, sep='')
elif a - b - c - d == 7:
    print(a, '-', b, '-', c, '-', d, '=', 7, sep='')

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

if a + b + c + d == 7:
    print(a, '+', b, '+', c, '+', d, sep='')
elif a + b + c - d == 7:
    print(a, '+', b, '+', c, '-', d, sep='')
elif a + b - c + d == 7:
    print(a, '+', b, '-', c, '+', d, sep='')
elif a + b - c - d == 7:
    print(a, '+', b, '-', c, '-', d, sep='')
elif a - b + c + d == 7:
    print(a, '-', b, '+', c, '+', d, sep='')
elif a - b + c - d == 7:
    print(a, '-', b, '+', c, '-', d, sep='')
elif a - b - c + d == 7:
    print(a, '-', b, '-', c, '+', d, sep='')
elif a - b - c - d == 7:
    print(a, '-', b, '-', c, '-', d, sep='')
Problem p03565 (python)

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

ls = len(sp)
lt = len(t)
ok = 1
s = list(sp)
for i in range(ls-1, -1, -1):
    ok = 1
    for j in range(lt):
        if i + j >= ls:
            ok = 0
            break
        if (sp[i+j] == t[j]) or (sp[i+j] == '?'):
            continue
        ok = 0
        break
    if ok == 1:
        for si in range(i, i+lt):
            s[si] = t[si - i]
        break

if ok == 1:
    print(''.join(s).replace("?", "a"))
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
sp = input()
t = input()

ls = len(sp)
lt = len(t)
ok = 1
s = list(sp)
print(s)
for i in range(ls):
    ok = 1
    for j in range(lt):
        if (sp[i+j] == t[j]) or (sp[i+j] == '?'):
            continue
        ok = 0
        break
    if ok == 1:
        for si in range(i, i+lt):
            s[si] = t[si - i]
            print(s[si], sep="")
        break

if ok == 1:
    for i in range(ls):
        if s[i] == '?':
            s[i] = 'a'
    print(str(s))
else:
    print("UNRESTORABLE")
Problem p03607 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
A.sort()
ans = 0
cnt = 1
for i in range(N-1):
    if A[i] == A[i + 1]:
        cnt += 1
        continue
    ans += cnt % 2
    cnt = 1
if cnt % 2 == 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0] * 100005
for i in range(N):
    a = int(input())
    A[a] = 1 - A[a]
ans = 0
for i in range(100005):
    ans += A[i]
print(ans)
Problem p03612 (python)

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

ans = 0
for i in range(N-1):
    if p[i] != i+1:
        continue
    tmp = p[i]
    p[i] = p[i+1]
    p[i+1] = tmp
    ans += 1
if p[N-1] == N:
    ans += 1
print(ans)

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

ans = 0
for i in range(N):
    if p[i] != i+1:
        continue
    tmp = p[i]
    p[i] = p[i+1]
    p[i+1] = tmp
    ans += 1
print(ans)
Problem p02553 (python)

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

ans = -float("INF")  # 答えがマイナスになることがあるので、負の無限大を初期値にしておきます

for x in (a, b):
    for y in (c, d):
        ans = max(ans, x * y)

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
ans = -float("INF")

x = for x in (a,b):
  for y in (c,d):
    ans = max(ans,X*y)
print(ans)
Problem p02576 (python)

Fixed submission:
N,X,T = map(int,input().split())
print(-(-N//X)*T)

Buggy submission (verdict: Runtime Error):
N,X,T = map(int,input().split())
print(-(-N//X*T)
Problem p02582 (python)

Fixed submission:
s = input()
ans = 0

for i in range(1,4):
  p = "R"*i
  if p in s:
    ans = i
    
print(ans)

Buggy submission (verdict: Runtime Error):
s = map(input().split())
ans = 0

for i in range(3):
  p = "R"*i
  if p in s:
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
s = map(input().split())
ans=0

for i in range(3):
  n = i*s
  if n in s:
    print(i)
Problem p02639 (python)

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

for i in range(5):
  if X[i]==0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
x = list(map(int,input()))
for i in range(5):
  if x[i]==0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
x = list(map(int,input()))
for i in range(5):
  if x[i]==0:
    print(i)

Buggy submission (verdict: Runtime Error):
x = list(map(int,input()))
for i in range(5):
  if find 0 in x:
    print(i)

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

for i in len(5):
  if X[i]==0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
X = list(map(int,input()))

for i in len(5):
  if X[i]==0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
X = list(map(int,input()))

for i in range(len(X)):
  if X[i]==0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
X = list(map(int,input()))

for i in X:
  if X[i]==0:
    print(i+1)
Problem p02687 (python)

Fixed submission:
print("ARC" if input()=="ABC" else "ABC")

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
hoge={}
for j in range(K):
    input()
    [hoge.update({int(j):1}) for j in input().split()]
print(sum([not j in hoge for j in range(N)]))
Problem p03341 (python)

Fixed submission:
N=int(input())
s=input()
e=0
w=0
for i in s:
    if(i=='W'):
        w+=1
    elif(i=='E'):
        e+=1
ans=[0,0]
dp=[-1 for _ in range(N)]

for i in range(N):
    tmp=ans[1]
    if(s[i]=='W'):
        ans[1]+=1
    else:
        ans[0]+=1
    dp[i]=tmp+(e-ans[0])

print(min(dp))

Buggy submission (verdict: Runtime Error):
N=int(input())
s=input()
import collections
a=collections.Counter(s)
a=sorted(a.items(),key=lambda x:x[0])
e=a[0][1]
w=a[1][1]

ans=[0,0]
dp=[-1 for _ in range(N)]

for i in range(N):
    dp[i]=ans[1]+(e-ans[0])
    if(s[i]=='W'):
        ans[1]+=1
    else:
        ans[0]+=1


print(min(dp))
Problem p03647 (python)

Fixed submission:
s=set()
N,M=map(int,input().split())
for i in range(M):
    a,b=map(int,input().split())
    s.add((a,b))

for i in range(N):
    if((1,i)in s and (i,N) in s):
        print("POSSIBLE")
        exit()
    
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for i  in range(size)]
    def find(self,x):
        if(self.table[x]<0):
            return x
        else :
            self.table[x]=self.find(self.table[x])
            return self.table[x]

    def union(self,x,y):
        s1 = self.find(x)        
        s2 = self.find(y)
        if s1 != s2:
            self.table[s2]=s1
        return


N,M=map(int,input().split())
uf=UnionFind(N+1)
for i in range(M):
    a,b=map(int,input().split())
    uf.union(a,b)

if(1==uf.find(N)):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03733 (python)

Fixed submission:
N,T=map(int,input().split())
t=list(map(int,input().split()))

ans=0
for i in range(0,len(t)-1):
        ans+=min(t[i+1]-t[i],T)
ans+=T
print(ans)

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

for i in range(0,len(t)-1):
        ans+=min(t[i+1]-t[i],T)
ans+=T
print(ans)
Problem p04001 (python)

Fixed submission:
N=input()
slen=len(N)-1
if(slen==0):
    print(N)
    exit()
ans=0
for i in range(2<<(slen-1)):
    k=N
    ins=0
    for j in range(slen): 
        if((i>>j)&1):
            k=k[:j+1+ins]+"+"+k[j+1+ins:]
            ins+=1
    ans+=eval(k)
print(ans)

Buggy submission (verdict: Runtime Error):
N=input()
slen=len(N)-1
ans=0
for i in range(2<<(slen-1)):
    k=N
    ins=0
    for j in range(slen): 
        if((i>>j)&1):
            k=k[:j+1+ins]+"+"+k[j+1+ins:]
            ins+=1
    ans+=eval(k)
print(ans)
Problem p02555 (python)

Fixed submission:
# D - Redistribution
S = int(input())
MOD = 10**9+7

# dp[i]: 3 以上の数字で i を作る組み合わせ
dp = [0]*(S+1)

if S <= 2:
    print(0)
elif S <= 5:
    print(1)
else:
    # 初期条件
    dp[3],dp[4],dp[5] = 1,1,1

    # i を作る組合わせ
    for i in range(6,S+1):
        dp[i] = dp[i-2] + dp[i-3] + dp[i-4]

    ans = (dp[S])%MOD
    print(ans)

Buggy submission (verdict: Runtime Error):
# D - Redistribution
S = int(input())
MOD = 10**9+7

# dp[i]: 3 以上の数字で i を作る組み合わせ
dp = [0]*(S+1)

# 初期条件
dp[3],dp[4],dp[5] = 1,1,1


# i を作る組合わせ
for i in range(6,S+1):
    dp[i] = dp[i-2] + dp[i-3] + dp[i-4]

ans = (dp[S])%MOD
print(ans)
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

lis = [[] for _ in range(N+1)]
for i in range(M):
    A,B = map(int,input().split())
    lis[A].append(B)
    lis[B].append(A)
    
cnt = 0
seen = [False]*(N+1)
def dfs(v,graph):
    global cnt
    seen[v] = True
    for next_v in graph[v]:
        if seen[next_v] == True:
             continue
        if seen[next_v] == []:
             continue
        cnt += 1
        dfs(next_v,graph)
    return cnt

ma = 0
for j in range(N):
    cnt = 0
    if seen[j] == True:
        continue
    ma = max(ma,dfs(j,lis))
print(ma+1)

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

lis = [[] for _ in range(N+1)]
for i in range(M):
    A,B = map(int,input().split())
    A,B = min(A,B),max(A,B)
    lis[A].append(B)

cnt = 0
seen = [False]*(N+1)
def dfs(v,graph):
    global cnt
    seen[v] = True
    for next_v in graph[v]:
        if seen[next_v] == True:
             continue
        if seen[next_v] == []:
             continue
        cnt += 1
        dfs(next_v,graph)
    return cnt

ma = 0
for j in range(N):
    cnt = 0
    if seen[j] == True:
        continue
    ma = max(ma,dfs(j,lis))
print(ma+1)
Problem p02621 (python)

Fixed submission:
a = int(input())

print(a**3 + a**2 + a)

Buggy submission (verdict: Runtime Error):
from collections import deque
N,M,K = map(int,input().split())
A = deque(map(int,input().split()))
B = deque(map(int,input().split()))

A.append(float('inf'))
B.append(float('inf'))

time = K 
count = 0
sum_A = sum(list(A)[:-1])
sum_B = sum(list(A)[:-1])
for _ in range(len(A)+len(B)):
    if A[0] > B[0]:
        target = B.popleft()
        if (target > (sum_A-A[0])) and len(A) != 1:
            sum_A -= A[0]
            B.appendleft(target) 
            target = A.popleft()
        time -= target
        count += 1
    else:
        target = A.popleft()
        if (target > (sum_B-B[0])) and len(B) != 1:
            sum_B -= B[0]
            A.appendleft(target)
            target = B.popleft()
        time -= target
        count += 1
    if len(A) == len(B) == 1:
        break
    if time < 0:
        count -= 1
        break 
    elif time == 0:
        break
print(count)
Problem p02639 (python)

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

print(a.index(0) + 1)

Buggy submission (verdict: Runtime Error):
#D - Not Divisible
import collections
N = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse = False)

#collections.Counterは存在しない値を指定すると0を返す
cnt = collections.Counter(a)
m = max(a)+1
for i in a:
    if cnt[i] >= 2:
        del cnt[i]
    for j in range(i*2,m,i):
        del cnt[j]
print(len(cnt.keys()))
Problem p02657 (python)

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

print(A*B)

Buggy submission (verdict: Runtime Error):
#D - Div Game
N = int(input())

def Prime_factorize(n):
    cnt = 0
    A = []
    #2の倍数で割っていく
    z = 2
    while n%z==0 and (n>=z):
        cnt += 1
        n //= z
        A.append(z)
        #割るたびに2倍
        z *= 2
    #割る始めの数をfとして保持
    while n%2 == 0:
        n//=2
    f = 3
    z = 3
    #sqrt(n)以内に全ての素因数は含まれる
    while f*f <= n:
        if n%z == 0:
            cnt += 1
            n //= z
            A.append(z)

            #割るたびにf倍
            z = z*f
        #fで割り切れなかったら(f+2)してf_divもリセット
        else:
            f += 2
            z = f

    #残ったnが以前に選んだもので割り切れないとき
    if n != 1 and all((n%i != 0 for i in A)):
        A.append(z)
        cnt += 1
    #素数のとき
    if cnt == 0:
        cnt = 1
    return cnt
if N == 1:
    ans = 0
else:
    ans = Prime_factorize(N)
print(ans)

Buggy submission (verdict: Runtime Error):
#D - Div Game
N = int(input())

def Prime_factorize(n):
    cnt = 0
    A = []
    #2の倍数で割っていく
    z = 2
    while n%z==0 and (n>=z):
        cnt += 1
        n //= z
        A.append(z)
        #割るたびに2倍
        z *= 2
    #割る始めの数をfとして保持
    f = 3
    z = 3
    #sqrt(n)以内に全ての素因数は含まれる
    while 2*f <= n:
        if n%z == 0:
            cnt += 1
            n //= z
            A.append(z)

            #割るたびにf倍
            z = z*f
        #fで割り切れなかったら(f+2)してf_divもリセット
        else:
            f += 2
            z = f

    #残ったnが以前に選んだもので割り切れないとき
    if n != 1 and all((n%i != 0 for i in A)):
        A.append(z)
        cnt += 1
    #素数のとき
    if cnt == 0:
        cnt = 1
    return cnt
if N == 1:
    ans = 0
else:
    ans = Prime_factorize(N)
print(ans)
Problem p02742 (python)

Fixed submission:
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
    count = 1
elif H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)

Buggy submission (verdict: Runtime Error):
#B - Bishop △(TLE,WA)
H,W = map(int,input().split())

count = 0
if H == 1 or W == 1:#コーナーケース(H,Wが1の時どこにも動けない)
if H % 2 == 0:
    count = (H // 2)*W
else :
    count = (H // 2)*W + ((W + 2 - 1) // 2)#x/yの切り上げ:(x+y-1)//y
print(count)
Problem p02743 (python)

Fixed submission:
# C - Sqrt Inequality
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
sqrt = decimal.Decimal(0.5)
if a**sqrt + b**sqrt < c**sqrt:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# C - Sqrt Inequality
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
rta,rtb,rtc = map(math.sqrt,[a,b,c])
sqrt = decimal.Decimal(0.5)
if a**sqrt + b**sqrt < c**sqrt:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# C - Sqrt Inequality
import math
import decimal
a,b,c = input().split()
a,b,c = map(decimal.Decimal,[a,b,c])
rta,rtb,rtc = map(math.sqrt,[a,b,c])
rta,rtb,rtc = map(srt,[rta,rtb,rtc])
rta,rtb,rtc = map(decimal.Decimal,[rta,rtb,rtc])

if rta + rtb < rtc:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# C - Sqrt Inequality
a,b,c = map(int,input().split())
rta,rtb,rtc = map(math.sqrt,[a,b,c])

if rta + rtb < rtc:
    print('Yes')
else:
    print('No')
Problem p02843 (python)

Fixed submission:
#70 C - 100 to 105 WA
X = int(input())

dp = [0]*(100010)
lst = [100,101,102,103,104,105]
for i in range(100,106):
    dp[i] = 1

# dp[v] が存在するなら 1, しないなら 0
for v in range(100,X+1):
    for w in range(6):
        n = lst[w]
        if dp[v-n] == 1:
            dp[v] = 1
print(dp[X])

Buggy submission (verdict: Runtime Error):
#70 C - 100 to 105 WA
X = int(input())

dp = [0]*(X+1)
lst = [100,101,102,103,104,105]
for i in range(100,106):
    dp[i] = 1

# dp[v] が存在するなら 1, しないなら 0
for v in range(100,X+1):
    for w in range(6):
        n = lst[w]
        if dp[v-n] == 1:
            dp[v] = 1
print(dp[X])
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
  if S[i] == T[i]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
#B - Power Socket
A,B = list(map(int,input().split()))

count = 0
total_plug = 1
for i in range(1,100):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Buggy submission (verdict: Runtime Error):
#B - Power Socket
A,B = input().split()
A = int(A)
B = int(B)

count = 0
total_plug = 1
for i in range(1,20):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Buggy submission (verdict: Runtime Error):
#B - Power Socket
A,B = input().split()
A = int(A)
B = int(B)

count = 0
total_plug = 1
for i in range(1,100):
    print(total_plug)
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Buggy submission (verdict: Runtime Error):
#B - Power Socket
A,B = list(map(int,input().split()))

count = 0
total_plug = 1
for i in range(1,100):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)

Buggy submission (verdict: Runtime Error):
#B - Power Socket
A,B = list(map(int,input().split()))

count = 0
total_plug = 1
for i in range(1,100):
    count += 1
    total_plug += (A - 1)
    if B <= total_plug:
        break
        
print(count)
Problem p02996 (python)

Fixed submission:
# 52 D - Megalomania
N = int(input())
work = []
for _ in range(N):
    a,b = map(int,input().split())
    work.append((a,b))

# 締め切りが早い順にソート
work = sorted(work,key = lambda x:x[1],reverse = False)

result = 'Yes'
t = 0
for i,j in work:
    t += i
    if t>j:
        result = 'No'
        break
print(result)

Buggy submission (verdict: Runtime Error):
#35 C - Anti-Division　
import math
A,B,C,D = map(int,input().split())

# C と D の最小公倍数の個数
lcm = C*D//math.gcd(C,D)
cnt_lcm = B//lcm - A//lcm

# C の倍数の個数
cnt_C = B//C - (A-1)//C 

# D の倍数の個数
cnt_D = B//D - (A-1)//D

# (範囲内の整数) - (C の倍数 + D の倍数 - C,D の公倍数)
ans = (B - A + 1) - (cnt_C + cnt_D - cnt_lcm)

# 範囲が 1 しかないとき
if A == B:
    # C でも D でも割り切れるとき
    if A%C == 0 and A%D == 0:
        print(0)
    else:
        print(1)
else:
    print(ans)
Problem p03037 (python)

Fixed submission:
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)
    
if L_max <= R_min:
    ans = R_min - L_max + 1
else:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
L_list = []
R_list = []
for o in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)

count = list(range(L_list[0],R_list[0]+1))
for i in range(1,M):
    count = list(count)
    if L_list[i] > count[0]:
        sta = L_list[i]
    else:
        sta = count[0]
    if R_list[i] > count[-1]:
        fin = count[-1]
    else:
        fin = R_list[i]
    count = set(count) & set(range(sta,fin+1))

ans = len(count)
print(ans)