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

Fixed submission:
import numpy as np
#import copy
#import fractions
#
###############入  力###################
#a, b, c, d = map(int, input().split())  # a=2 b=4 c=5 d =7
#a = list(map(int, input().split()))     # a = [2, 4, 5, 6]
#s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
##行数指定
##3
##hoge
##foo
##bar
#n=int(input())
#string_list=[input() for i in range(n)] #['hoge','foo','bar']
#
###############初期化、コピー##############
#a=[0]*5 #[0, 0, 0, 0, 0]
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#b2=a[:]  #1次元のときはコピーはこれで良い
#
###############小数点表示################
#a = 0.364364
#print(a) #0.364364
#print("{:.6f}".format(a)) #0.364364
#print("{:.4f}".format(a)) #0.3644 小数点第4位に丸めることもできる。
#
###############ゼロ埋め・幅寄せ################
#print("python".ljust(15,'-')) # 左詰め　　　 #python---------
#print("python".center(15,'-'))# 中央寄せ　　#-----python----
#print("python".rjust(15,'-')) # 右詰め　　　 #---------python
#print(str(29).rjust(10,'0')) #10桁ゼロ埋め　 #0000000029
#
###############文字列操作################
#'abc123def'[:] #すべての文字列が取れる #'abc123def'
#'abc123def'[-1:] #終端文字がとれる    #'f'
#'abc123def'[:-1] #最後の1文字以外のものがとれる。 #'abc123de'
#'abc123def'[::-1] #文字が逆転する #'fed321cba'
#
###############二分探索################
#import bisect
#listA=[1,2,5,2,4,6,7,8,6,56,3,56,76,34,32,2,6,0,32,6,0] 
#listA.sort()
#zeroindex=bisect.bisect_right(listA,0) #ソートされたリスト内で0の場所を探し、右側Indexを返す
#clearlistA=listA[zeroindex:]#0以下が存在しないリストを得る
#
#
###############最小公倍数,最大公約数
#import fractions
#a,b=map(int, input().split())
#a,b= 24, 6
#f=fractions.gcd(a,b)
#f2=a*b//f
#print(f,f2)
#
###############四則演算
#a + b #足し算（加算）: +演算子
#a - b#引き算（減算）: -演算子
#a * b#掛け算（乗算）: *演算子
#a / b#割り算（除算）: /演算子
#a// b#割り算の整数部（整数除算）: //演算子
#a % b#割り算の剰余（余り, mod）: %演算子
#a** b#べき乗: **演算子

X = int(input())
XX=np.arange(X,X+10**4)

s=0
for j in XX:
    if (s==1):
        break
    for i in range(2, j+1):
        N= j % i
#        print('j=' ,j ,' i=' ,i, N)
        if (N ==  0 and i==j ):
            print(j)
            s=1
        if (N ==  0):
          #  print('true')
            break
#        else:
#            print(j)

Buggy submission (verdict: Runtime Error):
X = int(input())
XX=np.arange(X,X+10**4)

s=0
for j in XX:
    if (s==1):
        break
    for i in range(2, j+1):
        N= j % i
#        print('j=' ,j ,' i=' ,i, N)
        if (N ==  0 and i==j ):
            print(j)
            s=1
        if (N ==  0):
          #  print('true')
            break
#        else:
#            print(j)

Buggy submission (verdict: Runtime Error):
X = int(input())
XX=np.arange(X,X+10**4)

s=0
for j in XX:
    if (s==1):
        break
    for i in range(2, j+1):
        N= j % i
#        print('j=' ,j ,' i=' ,i, N)
        if (N ==  0 and i==j ):
            print(j)
            s=1
        if (N ==  0):
          #  print('true')
            break
#        else:
#            print(j)
Problem p02835 (python)

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

if (sum(a) >= 22):
	print('bust' )
else:
	print('win')

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

if (sum(a) >= 22):
	print('bust' )
else:
  printa('win')
Problem p02829 (python)

Fixed submission:
a=int(input())
b=int(input())
Z=[1,2,3]
Z.remove(a)
Z.remove(b)

print(Z[0])

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
Z=[1,2,3]
X=Z.remove(a,b)

print(X)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
Z=list['1','2','3']
X=Z.remove(a,b)

print(X)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
Z=list['1','2','3']
X=Z.remove('a','b')

print(X)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
Z=list[1,2,3]
X=Z.remove(a,b)

print(X)
Problem p02915 (python)

Fixed submission:
N = int(input())
print(N**3)

Buggy submission (verdict: Runtime Error):
N = int(inpput())
print(N**3)
Problem p03017 (python)

Fixed submission:
N, A, B, C, D = map(int, input().split())
S = input()
Sac = S[A-1:C]
Sbd = S[B-1:D]
if "##" in Sac or "##" in Sbd:
    print("No")
elif C < D:
    print("Yes")
elif "..." in Sbd:
    print("Yes")
else:
    s1 = S[A-1:B-1] + "#" + S[B:C]
    s2 = S[A-1:D-1] + "#" + S[D:C]
    if "##" not in s1 or "##" not in s2:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = input()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = []
if C < D:
    S1 = S[A: D-1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    if ans1 < 2:
        print("Yes")
    else:
        print("No")
else:
    S1 = S[A: C-1]
    S2 = S[B: D+1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    for j in S2:
        if i == ".":
            cou2 += 1
        else:
            ans2.append(cou2)
            cou2 = 0
    if ans1 < 2 and min(ans2) >= 3:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = input()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = []
if C < D:
    S1 = S[A: D-1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    if ans1 < 2:
        print("Yes")
    else:
        print("No")
else:
    S1 = S[A: C-1]
    S2 = S[B: D+1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    for j in S2:
        if i == ".":
            cou2 += 1
        elif cou2 != 0:
            ans2.append(cou2)
            cou2 = 0
    if ans1 < 2 and min(ans2) >= 3:
        print("Yes")
    else:
        print("No")
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S=input()
if S[K-1] == "A":
    ans = S[:K-1] + "a" + S[K:]
elif S[K-1] == "B":
    ans = S[:K-1] + "b" + S[K:]
else:
    ans = S[:K-1] + "c" + S[K:]
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S=input()
if S[K] == "A":
    ans = S[:K] + "a" + S[K+1:]
elif S[K] == "B":
    ans = S[:K] + "b" + S[K+1:]
else:
    ans = S[:K] + "c" + S[K+1:]
print(ans)
Problem p03077 (python)

Fixed submission:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
m = min(A, B, C, D, E)
if N % m == 0:
    print(N // m + 4)
else:
    print(N // m + 5)

Buggy submission (verdict: Runtime Error):
N = input()
A = input()
B = input()
C = input()
D = input()
E = input()
mLsit = [A, B, C, D, E]
m = min(mList)
if N % m == 0:
    print(N // m)
else:
    print(N // m + 1)

Buggy submission (verdict: Runtime Error):
N = input()
ABCDE = []
for i in range(4):
    A = input()
    ABCDE.append(A)
m = min(ABCDE)
if N % m == 0:
    print(N // m)
else:
    print(N // m + 1)

Buggy submission (verdict: Runtime Error):
N = input()
ABCDE = []
for i in range(4):
    A = input()
    ABCDE.append(A)
m = min(ABCDE)
if N % n == 0:
    print(N // m)
else:
    print(N // m + 1)

Buggy submission (verdict: Runtime Error):
N = input()
ABCDE = []
for i in range(5):
    A = input()
    ABCDE.append(A)
m = min(ABCDE)
if N % n == 0:
    print(N // m)
else:
    print(N // m + 1)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
mod = 1e+9+7
flags = [True  for i in range(N+1)]
for i in range(M):
    tmp = int(input())
    flags[tmp-1] = False
dp = [0 for i in range(N+1)]
dp[0] = 1
dp[1] = 2

if not flags[0]:
    dp[0] = 0
    dp[1] = 1
if not flags[1]:
    dp[1] = 0
for i in range(2, N):
    if flags[i]:
        dp[i] = int((dp[i-1] + dp[i-2]) % mod)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
mod = 1e+9+7
flags = [True  for i in range(N)]
for i in range(M):
    tmp = int(input())
    flags[tmp-1] = False
dp = [0 for i in range(N)]
dp[0] = 1
dp[1] = 2

if not flags[0]:
    dp[0] = 0
    dp[1] = 1
if not flags[1]:
    dp[1] = 0
for i in range(2, N):
    if flags[i]:
        dp[i] = int((dp[i-1] + dp[i-2]) % mod)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
mod = 1e+9+7
flags = [True  for i in range(N)]
for i in range(M):
    tmp = int(input())
    flags[tmp-1] = False
dp = [0 for i in range(N)]
dp[0] = 1
dp[1] = 2

if not flags[0]:
    dp[0] = 0
    dp[1] = 1
if not flags[1]:
    dp[1] = 0
for i in range(2, N):
    if flags[i]:
        dp[i] = int((dp[i-1] + dp[i-2]) % mod)
print(dp)
Problem p03208 (python)

Fixed submission:
n,k = map(int,input().split())
h_list = [int(input()) for _ in range(n)]
h_list.sort(reverse=True)
i = 0
j = k-1
ans = 10**9

while j < n:
    diff = h_list[i]-h_list[j]
    ans = min(ans,diff)
    i += 1
    j += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h_list = [int(input()) for _ in range(n)]
h_list.sort()
i = 0
j = k-1
ans = 10**9

while j <= n:
    diff = abs(h_list[i]-h_list[j])
    ans = min(ans,diff)
    i  = j
    j += k-1
print(ans)
Problem p02836 (python)

Fixed submission:
import math
S = str(input())
length = len(S)
 
count = 0
for i in range(math.floor(length/2)):
    if S[i] != S[length-i-1]:
        count += 1
        
if count < length/2:
    print(count)
else:
    print(math.floor(length/2))

Buggy submission (verdict: Runtime Error):
import math
S = str(input())
len = len(S)

count = 0
for i in range(len):
  while count > len/2 or i == len:
	if S[i] != S[len-i]:
    	count += count
if count < len/2:
  print(count)
else:
  print(math.floor(len/2))
Problem p02829 (python)

Fixed submission:
import sys

A = input()
B = input()

if A == '1':
    if B == '2':
        print('3')
    else:
        print('2')
elif A == '2':
    if B == '1':
        print('3')
    else:
        print('1')
elif A == '3':
    if B == '1':
        print('2')
    else:
        print('1')

Buggy submission (verdict: Runtime Error):
import sys

A = input()
B = input()

if A = 1:
    if B = 2:
        print(3)
    else:
        print(2)
elif A = 2:
    if B = 1:
        print(3)
    else:
        print(1)
elif A = 3:
    if B = 1:
        print(2)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
A = input()
B = input()

if A = 1:
    if B = 2:
        print(3)
    else:
        print(2)
elif A = 2:
    if B = 1:
        print(3)
    else:
        print(1)
elif A = 3:
    if B = 1:
        print(2)
    else:
        print(1)
Problem p02831 (python)

Fixed submission:
import sys
a, b = input().split()

A = int(a)
B = int(b)

Adiv = A
Bdiv = B
k = 0




for i in reversed(range(min([A, B]))):
    j = i+1
    if Adiv % j == 0 and Bdiv % j == 0:
        k = j
        break


if k == 0:
    k = 1


res = A * B / k

print(int(res))

Buggy submission (verdict: Runtime Error):
import sys
a, b = input().split()

A = int(a)
B = int(b)

Adiv = A
Bdiv = B
k = 0




for i in reversed(range(min([A, B]))):
    j = i+1
    if Adiv % j == 0 and Bdiv % j == 0:
        k = j
    else:
        break

res = A * B / k
print(int(res))

Buggy submission (verdict: Runtime Error):
import sys
a, b = input().split()

A = int(a)
B = int(b)

Adiv = A
Bdiv = B
k = 0

n = int(10000)
primeN = []
for i in range(2, n):
    for j in range(2, i+1):
        if i % j == 0:
            if i == j:
                primeN.append(i)
            else:
                break



for i in range(min([A, B])):
    j = primeN[i]
    if Adiv % j == 0 and Bdiv % j == 0:
        k = j
    else:
        break

res = A * B / k
print(int(res))
Problem p03041 (python)

Fixed submission:
def main():
    N,K = map(int, input().split())
    S = input()
    if K == 1:
        print(S[0].lower() + S[1:])
    elif K == N:
        print(S[:N-1] + S[N-1].lower())
    else:
        print(S[0:K-1] + S[K-1].lower() + S[K:])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N,K = map(int, input().split())
    S =	input()
    if K == 1:
	print(S[0].lower() + S[1:])
    elif K == N:
	print(S[:N-1] + S[N-1].lower())
    else:
      	print(S[0:K-1] + S[K-1].lower() + S[K:])

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

Fixed submission:
def main():
    string = raw_input()
    A = string[0]
    B = string[1]
    C = string[2]
    if A == '1':
        A = '9'
    else:
        A = '1'
    if B == '1':
        B = '9'
    else:
        B = '1'
    if C == '1':
        C = '9'
    else:
        C = '1'        
    print(A+B+C)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
 
def main():
    n = input()
    a = map(int, raw_input().split())
    odd = [a[2 * i] for i in range(n/2)]
    even = [a[2*i + 1] for i in range(n/2)]
    codd = collections.Counter(odd)
    ceven = collections.Counter(even)
    coddmostitem = codd.most_common()[0][0]
    coddmosttimes = codd.most_common()[0][1]
    cevenmostitem = ceven.most_common()[0][0]
    cevenmosttimes = ceven.most_common()[0][1]
    if coddmostitem == cevenmostitem:
        if coddmosttimes >= cevenmosttimes:
            if len(ceven) == 1:
                cevennoreplace = 0
            else:
                cevennoreplace = ceven.most_common()[1][1]
            coddnoreplace = codd.most_common()[0][1]
        if coddmosttimes < cevenmosttimes:
            if len(codd) == 1:
                coddnoreplace = 0
            else:
                coddnoreplace = codd.most_common()[1][1]
            cevennoreplace = ceven.most_common()[0][1]
    else:
        coddnoreplace = codd.most_common()[0][1]
        cevennoreplace = ceven.most_common()[0][1]
    coddreplace = n/2 - coddnoreplace
    cevenreplace = n/2 - cevennoreplace
    print(coddreplace+cevenreplace)
 
if __name__ == '__main__':
    main()
Problem p02819 (python)

Fixed submission:
x = int(input())

while True:
    flg = True
    for i in range(2, x//2+1):
        if x % i == 0.0:
            flg = False
            break
    if flg:
        print(x)
        break
    x += 1

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

while True:
    flg = True
    for i in range(2, x):
        if x % i == 0.0:
            flg = False
            break
    if flg:
        print(x)
        break
    x += 1
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    if a > b:
        a, b = (b, a)
    while b:
        a, b = b, a % b
    return a


def main():
    a, b = map(int, input().split())
    ans = round(a * b / gcd(a, b))
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    a, b = map(int, input().split())
    ans = round(a * b / math.gcd(a, b))
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    a, b = map(int, input().split())
    ans = "{:.0f}".format(a * b / math.gcd(a, b))
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math


def main():
    a, b = map(int, input().split())
    ans = "{:.0f}".format(a * b / math.gcd(a, b))
    print(ans)


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

Fixed submission:
def main():
    A1, A2, A3 = map(int, input().split())

    if A1+A2+A3 >= 22:
        print("bust")
    else:
        print("win")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    sum = 0

    for i in range(60):
        count_1 = 0
        for a in a_list:
            bin_a = format(a, "b").zfill(60)
            if bin_a[59-i] == "1":
                count_1 += 1

        sum += 2 ** i * count_1 * (N - count_1)

    print(sum % mod)


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

Fixed submission:
import heapq


def main():
    n, m = map(int, input().split())
    a_list = list(map(lambda x: -int(x), input().split()))

    heapq.heapify(a_list)
    for _ in range(m):
        a = heapq.heappop(a_list)
        heapq.heappush(a_list, -(-a // 2))

    print(-sum(a_list))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    sorted_a_list = sorted(a_list, reverse=True)

    for _ in range(m):
        sorted_a_list[0] = int(sorted_a_list[0]/2)
        if sorted_a_list[0] < sorted_a_list[1]:
            sorted_a_list = sorted(sorted_a_list, reverse=True)

    print(sum(sorted_a_list))


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

Fixed submission:
from sys import exit, stderr, stdin
input = stdin.readline
import heapq
# from collections import defaultdict
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N,M = [int(n) for n in input().split()]
    # {期限:価値}
    jobs = [[]]*N
    v = 0
    for i in range(N):
        jobs[i] = [int(n) for n in input().split()]
    # 価値降順→期間昇順
    jobs = sorted(jobs,key=lambda x:-x[1])
    jobs = sorted(jobs,key=lambda x:x[0])
    cur = 0
    ans = 0
    cand = []
    for i in range(1,M+1):
        while(cur < N and i >= jobs[cur][0]):
            heapq.heappush(cand,-jobs[cur][1])
            cur += 1
        if len(cand) != 0:
            ans -= cand[0]
            heapq.heappop(cand)
    print(ans)



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N,M = [int(n) for n in input().split()]
    jobs = [[] for _ in range(10000)]
    v = 0
    for i in range(N):
        a,b = [int(n) for n in input().split()]
        if a <= M:
            jobs[b].append((a,b))
            v = max(v,b)
    jobs = jobs[:v+1]
    # 時間でソート(昇順)
    for i in range(v):
        jobs[i] = sorted(jobs[i])

    # debug(jobs, "(期限、価値) in [価値]")
    ans = 0
    jobs_k = len(jobs)-1

    for i in range(jobs_k,-1,-1):
        while(len(jobs[i]) != 0 and jobs[i][-1][0] <= M):
            ans+=jobs[i][-1][1]
            M-=1
            jobs[i].pop()
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N,M = [int(n) for n in input().split()]
    jobs = [[] for _ in range(10000)]
    v = 0
    for i in range(N):
        a,b = [int(n) for n in input().split()]
        if a <= M:
            jobs[b].append((a,b))
            v = max(v,b)
    jobs = jobs[:v+1]
    # 時間でソート(昇順)
    for i in range(v):
        jobs[i] = sorted(jobs[i])

    # debug(jobs, "(期限、価値) in [価値]")
    ans = 0
    jobs_k = len(jobs)-1

    while(M>0 or jobs_k != 0):
        for i in range(jobs_k,-1,-1):
            if len(jobs[i]) == 0:
                jobs.pop()
                if len(jobs)==0:
                    M = 0
                    break
                continue
            if jobs[i][-1][0] > M:
                jobs[i].pop()
            else:
                ans += jobs[i][-1][1]
                jobs[i].pop()
                M -= 1
                break
        jobs_k = max(len(jobs)-1,0)
    print(ans)


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

Fixed submission:
K, S = map(int, input().split())

result = 0

for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            result += 1

print(result)

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

result = 0

for x in range(K + 1):
    for y in range(K + 1):
        Z = S - X - Y
        if 0 <= Z and  Z <= K:
            result += 1

print(result)

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

result = 0

for x in range(K + 1):
    for y in range(K + 1):
        Z = S - X - Y
        if 0 <= Z <= K:
            result += 1

print(result)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
import math
def lcm(x, y):
    return (x * y) // gcd(x, y)

x,y = map(int,input().split())
print(lcm(x,y))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

x,y = map(int,input().split())
print(lcm(x,y))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

x,y = map(int,input().split())
print(lcm(x,y))
Problem p02891 (python)

Fixed submission:
s = [c for c in input()]
k = int(input())

import copy

if len(s) == 1:
    print(k//2)

elif len(s) == len(set(s)):
    print(0)
    
elif s[0] != s[-1]:
    c = 0
    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            c = c + 1
            s[i] = 'Z'
    print(c*k)

else: # s[0]==s[-1]
    s2 = copy.copy(s)
    c = 0
    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            c = c + 1
            s[i] = 'Z'
    if s[-1] == 'Z':
        print(c*k)
    else:
        c2 = 1
        s2[0] = 'Z'
        for i in range(1, len(s)):
            if s2[i-1] == s2[i]:
                s2[i] = 'Z'
                c2 = c2 + 1
        if s2[-1] == 'Z':
            if k % 2 == 0:
                print(int((c+c2)*(k/2)))
            else:
                print(int((c+c2)*((k-1)/2)+c))
        else:
            print(c + c2*(k-1))

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

print(x * (x+1))
Problem p02897 (python)

Fixed submission:
n = int(input())

if n%2==0:
    print(1/2)
else:
    print((n+1)/2/n)

Buggy submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

#import numpy as np

a, b = map(int, input().split())
if a==1 and b==1:
    print(1)
else:
    #print(factorization(a))
	prime_a = factorization(a)
	prime_b = factorization(b)
	#print(prime_a, prime_b)
	print(1+len(set(prime_a)&set(prime_b)))
Problem p02897 (python)

Fixed submission:
n = int(input())
if n == 1:
  print (n)
else:
  if n % 2 == 1:
    print((n//2+1)/n)
  else:
    print(1/2)

Buggy submission (verdict: Runtime Error):
n = input()
if n == 1:
  print (n)
else:
  if n % 2 == 1:
    print(0.6)
  else:
    print(0.5)
Problem p02847 (python)

Fixed submission:
days = ['SUN','MON','TUE','WED','THU','FRI','SAT']
s = input().rstrip()
index = days.index(s)
for i in range(7):
    ni = (index + i + 1) % 7
    if days[ni] == 'SUN':
        print(i + 1)
        break

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

prev_max_number = 0
answer = -1
for i in range(10):
    baseline = b * (i + 1)
    offset = (x - baseline) // a
    min_number = (10 ** i)
    max_number = (10 ** (i + 1)) - 1

    if offset < min_number:
        answer = prev_max_number
        break

    if offset < max_number:
        answer = offset
        break

    prev_max_number = max_number

if answer < (10 ** 9):
    print(answer)
else:
    print(10 ** 9)
Problem p02879 (python)

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

if A < 10 and B < 10:
    print(A*B)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

# 入力
N = int(input())

ans = 10**12
square = math.ceil(math.sqrt(N))
for i in range(1, square):
    if N%i == 0:
        ans = min(ans, int(N/i))
b = int(N/ans)
print(ans + b-2)