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

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np

x = int(input())
flg = 0

for i in range(1, x+1):
    if x % i != 0:
        continue
    else:
        for a in range(x):
            b = a - i
            if a**5 - b**5 == x:
                ans_a = a
                ans_b = b
                flg = 1
                break
            elif a > i and a**5 - b**5 > x:
                flg = -1
                break
        if flg == 1:
            break
        elif flg == -1:
            flg = 0
            continue

print(ans_a, ans_b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

x = int(input())
s_candidates = []


for i in range(1, x+1):
    if x % i != 0:
        continue
    else:
        for a in range(x):
            b = a - s
            if a**5 - b**5 == x:
                ans_a = a
                ans_b = b
                break
        if t == tmp:
            break

print(ans_a, ans_b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

x = int(input())
s_candidates = []


for i in range(1, x):
    if x % i == 0:
        s_candidates.append(i)

for s in s_candidates:
    for a in range(x):
        b = a - s
        t = x / s
        tmp = a**4 + (a**3) * b + (a**2) * (b**2) + a * (b**3) + b**4
        if t == tmp:
            ans_a = a
            ans_b = b
            break
    if t == tmp:
        break

print(ans_a, ans_b)
Problem p02705 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#import numpy as np

r = int(input())

ans = r * 2 * 3.14159265

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

r = int(input())

ans = r * 2 * np.pi()

print(ans)
Problem p02720 (python)

Fixed submission:
l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
l_temp = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def f(x):
    temp = list(str(x))
    t = int(temp[-1])
    if t == 0:
        return int(str(x) + str(t)), int(str(x) + str(t + 1))
    elif t == 9:
        return int(str(x) + str(t - 1)), int(str(x) + str(t))
    else:
        return int(str(x) + str(t - 1)), int(str(x) + str(t)), int(str(x) + str(t + 1))
       

while len(l) < 10 ** 5:
    temp = []
    for l_t in l_temp:
        tem = list(f(l_t))
        for t in tem:
            temp.append(t)
    for t in temp:
        l.append(t)
    l_temp = temp

K = int(input())
print(l[K-1])

Buggy submission (verdict: Runtime Error):
import heapq
l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
heapq.heapify(l)

def f(x):
    # xの最後の数値だけ取り出す
    min_x = int(list(str(x))[-1])
    if min_x == 0:
        yield int(x + "0")
        yield int(x + "1")
    elif min_x == 9:
        yield int(x + "8")
        yield int(x + "9")
    else:
        yield int(x + str(min_x - 1))
        yield int(x + str(min_x))
        yield int(x + str(min_x + 1))

K = int(input())
ans = 1
for i in range(K):
    if i == K - 1:
        ans = heapq.heappop(l)
        break
    for y in f(heapq.heappop(l)):
        heapq.push(l, y)
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
heapq.heapify(l)

def f(x):
    # xの最後の数値だけ取り出す
    min_x = int(list(str(x))[-1])
    if min_x == 0:
        yield int(x + "0")
        yield int(x + "1")
    elif min_x == 9:
        yield int(x + "8")
        yield int(x + "9")
    else:
        yield int(x + str(min_x - 1))
        yield int(x + str(min_x)
        yield int(x + str(min_x + 1)))

K = int(input())
ans = 1
for i in range(K):
    if i == K - 1:
        ans = heapq.heappop(l)
        break
    for y in f(heapq.heappop(l)):
        heapq.push(l, y)
print(ans)
Problem p02780 (python)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
P = list(map(int, input().split()))

kitai = [None]*(1001)
for i in range(1, 1001):
    kitai[i] = (0.5*i*(i+1))/i

ruiseki = P.copy()
ruiseki[K-1] = sum(ruiseki[0:K])
for i in range(K, N):
    ruiseki[i] = ruiseki[i-1]+P[i]-P[i-K]

ind = np.array(ruiseki).argmax()
temp = P[ind-K+1:ind+1]
ans = 0
for t in temp:
    ans+=kitai[t]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
P = list(map(int, input().split()))

kitai = [None]*(1001)
for i in range(1, 1001):
    kitai[i] = (0.5*i*(i+1))/i

ruiseki = [None]*(N-K+1)
for i in range(0, N-K+1):
    ruiseki[i] = sum(P[i:i+K])

ind = np.array(ruiseki).argmax()
temp = P[ind:ind+K]
ans = 0
for t in temp:
    ans+=kitai[t]
print(ans)
Problem p02909 (python)

Fixed submission:
S = input()
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
elif S == "Rainy":
    print("Sunny")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
N_original = N

ans = 0
isleft = True

def f(n):
    for i in range(N_original - n+1):
        temp = S[i:i+n]
        if temp in S[i+n:]:
            return True
    return False

left = 0
right = N
N = N//4
while True:
    if f(N):
        if left == N:
            ans = left
            break
        left = N
    else:
        if right == N:
            ans = right
            break
        right = N
    N = (left + right)//2
print(ans)
Problem p02913 (python)

Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0
for kosu in range(1, N//2+1):
    hantei = False
    for i in range(N-kosu):
        if hantei:
            break
        else:
            temp = S[i:i+kosu]
            # print("temp:", temp)
            # print("比較する文字列",S[0:i] + "|" + S[i+1:])
        if temp in S[0:i]+S[i+1:]:
            # print("Trueの時")
            ans = len(list(temp))
            hantei = True
            breaks
print(ans)
Problem p02918 (python)

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

a = []
temp = S[0]
s = []
ans = 0

if len(S) > 1 and temp == S[1]:
    hantei = True
    a.append(temp)
else:
    hantei = False
    s.append(list(S[0]))

for i in range(1, N):
    if temp == S[i]:
        ans += 1
    if hantei and temp != S[i]:
        s.append(a)
        a = []
        hantei = False
    if temp != S[i] or hantei:
        hantei = True
        a.append(S[i])
        temp = S[i]
if len(S) > 1:
    s.append(a)

length = len(s)
for i in range(K):
    if length > 2:
        ans += 2
        length -= 2
    elif length == 2:
        ans += 1
        break

print(ans)

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

a = []
temp = S[0]
s = []
ans = 0

if temp == S[1]:
    hantei = True
    a.append(temp)
else:
    hantei = False
    s.append(list(S[0]))


for i in range(1, N):
    if temp == S[i]:
        ans += 1
    if hantei and temp != S[i]:
        s.append(a)
        a = []
        hantei = False
    if temp != S[i] or hantei:
        hantei = True
        a.append(S[i])
        temp = S[i]
s.append(a)

length = len(s)
for i in range(K):
    if length > 2:
        ans += 2
        length -= 2
    elif length == 2:
        ans += 1
        break

print(ans)

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

a = []
temp = S[0]
hantei = False
s = []
n = []

for i in range(1, N):
    if hantei and temp != S[i]:
        s.append(a)
        n.append(len(a))
        a = []
    if temp != S[i] or hantei:
        hantei = True
        a.append(S[i])
        temp = S[i]

s.insert(0, list(S[0]))
s.append(list(S[-1]))
ans = 0
for i in range(K):
    ans = ans + 1 + max(n)
    k = n.index(max(n))
    n[k] = 0
print(ans)
Problem p02924 (python)

Fixed submission:
N = int(input())

ans =  (N*(N-1)) // 2
print(int(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())

ans =  N(N-1)/2

print(int(ans))
Problem p02945 (python)

Fixed submission:
A, B = map(int, input().split())
print(max(A+B, A-B, A*B))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [list(input()) for _ in range(N)]
S = []
for i in range(N):
    S.append("".join(sorted(s[i])))
print(S)

cnt = 0
for i in range(N):
    cnt += S.count(S[i]) - 1
print(int(cnt / 2))
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())

if R - L >= 2018:
      ans = 0
else:
    tempL = L%2019
    tempR = R%2019
    if tempR - tempL < R-L-1:
        temp = tempL
        tempL = 0
        X = list(range(tempL,temp))
        Y = list(range(tempR,2018+1))
        Z = X + Y
    else:
        Z = list(range(tempL,tempR+1))

    ans = 2019
    for i in range(len(Z)):
        for j in range(i+1, len(Z)):
            if (Z[i]*Z[j])%2019 < ans:
                ans = (Z[i]*Z[j])%2019
print(ans)

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

if R - L >= 2018:
      mod = 0
else:
    tempL = L%2019
    tempR = R%2019
    if tempR - tempL < R-L-1:
        temp = tempL
        tempL = 0
        X = list(range(tempL,temp))
        Y = list(range(tempR,2018+1))
        Z = X + Y
    else:
        Z = list(range(tempL,tempR+1))

ans = 2019
for i in range(len(Z)):
    for j in range(i+1, len(Z)):
        if (Z[i]*Z[j])%2019 < ans:
            ans = (Z[i]*Z[j])%2019
print(ans)

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

if R - L >= 2018:
      mod = 0
else:
    tempL = L%2019
    tempR = R%2019
    if tempR - tempL < R-L-1:
        temp = tempL
        tempL = 0
        X = range(tempL,temp)
        Y = range(tempR,2018)
        Z = extend(X,Y+1)
    else:
        Z = range(tempL,tempR+1)

ans = 2019
for i in range(len(Z)):
    for j in range(i+1, len(Z)):
        if (Z[i]*Z[j])%2019 < ans:
            ans = (Z[i]*Z[j])%2019
print(ans)
Problem p02995 (python)

Fixed submission:
import math
def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

A,B,C,D = map(int,input().split())

count = 0
lcm = C*D // gcd(C,D)


print(B - B//C - B//D + B//lcm - (A - 1 - (A-1)//C - (A-1)//D + (A-1)//lcm))

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

count = 0
len = B-A+1

count += math.floor(B/C)
count -= math.floor((A-1)/C)
count += math.floor(B/D)
count -= math.floor((A-1)/D)

lcm = C*D / math.gcd(C,D)
count -= math.floor(B/lcm)
count += math.floor((A-1)/lcm)

print(len - count)

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

count = 0
len = B-A+1

count += math.floor(B/C)
count -= math.floor((A-1)/C)
count += math.floor(B/D)
count -= math.floor((A-1)/D)

lcm = C*D / math.gcd(C,D)
count -= math.floor(B/lcm)
count += math.floor((A-1)/lcm)

print(len - count)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int,input().split())
hantei = 0
if (x != 0) and (y != 0):
    if (W/2 == x) and (H/2 == y):
        hantei = 1
print("{0} {1}".format(W*H/2, hantei))

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int,input().split())
hantei = 0
if (x != 0) or (y != 0):
    if (W%x == 0):
        if y*(W/x) == H:
            hantei = 1
print("{0} {1}".format(W*H/2, hantei))

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int,input().split())
hantei = 0
if (W%x == 0):
    if y*(W/x) == H:
        hantei = 1
print("{0} {1}".format(W*H/2, hantei))

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int,input().split())
hantei = 0
if (W%x == 0) and (H%y == 0):
    hantei = 1
print("{0} {1}".format(W*H/2, hantei))
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
str = input()
length = [list(map(int, input().split())) for _ in range(Q)]

ans = [0 for _ in range(N)]
for i in range(1, N):
    if (str[i-1] == "A") and (str[i] == "C"):
        ans[i] = ans[i-1] + 1
    else:
        ans[i] = ans[i-1]

for l1, l2 in length:
    # print(ans)
    print(ans[l2-1] - ans[l1-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
str = input()
length = [list(map(int, input().split())) for _ in range(Q)]

ans = [0 for _ in range(N)]
for i in range(1, N):
    if (str[i-1] == "A"):
        if (str[i] == "C"):
            ans[i] = ans[i-1] + 1
        else:
            ans[i] = ans[i-1]
    else:
        ans[i] = ans[i-1]
        ans[i+1] = ans[i-1]
        i += 1

for l1, l2 in length:
    # print(ans)
    print(ans[l2-1] - ans[l1-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
str = input()
length = [list(map(int, input().split())) for _ in range(Q)]

ans = [0 for _ in range(N)]
for i in range(1, N):
    if (str[i-1] == "A")
        if (str[i] == "C"):
            ans[i] = ans[i-1] + 1
        else:
            ans[i] = ans[i-1]
    else:
        ans[i] = ans[i-1]
        ans[i+1] = ans[i-1]
        i += 1

for l1, l2 in length:
    # print(ans)
    print(ans[l2-1] - ans[l1-1])
Problem p03160 (python)

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

dp = [0] * N
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, N):
    compare1 = dp[i-1] + abs(h[i]-h[i-1])
    compare2 = dp[i-2] + abs(h[i]-h[i-2])
    dp[i] = min(compare1, compare2)

print(dp[-1])

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

ans_list = [0]*N
ans_list[1] = abs(cost[0] - cost[1])
temp = 10 **10

for i in range(2,N):
    temp = 10**10
    for j in range(1,K+1):
        if i-j >=0:
            compare = ans_list[i-j] + abs(cost[i-j]-cost[i])
            temp = min(compare, temp)
        else:
            break
    ans_list[i] = temp
print(ans_list.pop())
Problem p03206 (python)

Fixed submission:
D = int(input())
if D == 25:
  print("Christmas")
elif D == 24:
  print("Christmas Eve")
elif D == 23:
  print("Christmas Eve Eve")
else:
  print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]

# 小さい順にソートする
#def sort(h):
#    if len(h) <= 1:
        return h
#    base = h[-1]
#    low_temp = [];
#    high_temp = [];
#    base_count = 1
#    for i in range(len(h)-1):
#        if h[i] < base:
#            low_temp.append(h[i])
#        elif h[i] > base:
#            high_temp.append(h[i])
#        else:
#            base_count += 1
#    low = sort(low_temp)
#    high = sort(high_temp)
#    return low + [base]*base_count + high

h.sort()
hantei = 10**10
for i in range(N-K+1):
    temp = h[i:i+K]
    temp_dif = max(temp) - min(temp)
    if temp_dif < hantei:
        hantei = temp_dif

print(hantei)
Problem p03284 (python)

Fixed submission:
N, K = map(int, (input().split()))
if N % K == 0:
    print("0")
else:
    print("1")

Buggy submission (verdict: Runtime Error):
N, K = map(int(input().split()))
if N % K == 0:
    print("0")
else:
    print("1")

Buggy submission (verdict: Runtime Error):
N, K = int(input().split())
if N % K == 0:
    print("0")
else:
    print("1")

Buggy submission (verdict: Runtime Error):
N, K = input().split()
if N % K == 0:
    print("0")
else:
    print("1")
Problem p03288 (python)

Fixed submission:
R = int(input())
if R < 1200:
    print("ABC")
elif R < 2800:
    print("ARC")
else:
    print("AGC")

Buggy submission (verdict: Runtime Error):
R = int(input())
if R < 1200:
    print("ABC")
elif R < 2800:
    print(ARC)
else:
    print(AGC)
Problem p03415 (python)

Fixed submission:
row = 3
column = 3
c=[]

for i in range(1, (row+1)):
    c.append(input())

print(c[0][0],c[1][1],c[2][2],sep="")

Buggy submission (verdict: Runtime Error):
row = 3
column = 3
c=[]

for i in range(1, (row+1)):
    c.append(list(map(str, input().split())))
print(c[0][0],c[1][1],c[2][2],sep="")
Problem p03477 (python)

Fixed submission:
Weight = list(map(int, input().split()))
if (Weight[0] + Weight[1]) > (Weight[2] + Weight[3]):
    print("Left")
elif (Weight[0] + Weight[1]) < (Weight[2] + Weight[3]):
    print("Right")
else:
    print("Balanced")

Buggy submission (verdict: Runtime Error):
Weiht = list(map(int, input().split()))
if (Weight[0] + Weight[1]) > (Weight[2] + Weight[3]):
    print("Left")
elif (Weight[0] + Weight[1]) < (Weight[2] + Weight[3]):
    print("Right")
else:
    print("Balanced")
Problem p03574 (python)

Fixed submission:
H, W = map(int, input().split())

M = [list("." + input() + ".") for i in range(H)]
M.insert(0, list(("."*(W+2))))
M.append(list("."*(W+2)))

cnt = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == ".":
            for k in range(-1, 2):
                if M[i+k][j-1] == "#":
                    cnt += 1
                if M[i+k][j] == "#":
                    cnt += 1
                if M[i+k][j+1] == "#":
                    cnt += 1
            print(cnt, end = "")
            cnt = 0
        else:
            print("#", end = "")
    print()

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

M = [["."*W]]
M = [[".", *input(), "."] for i in range(H)]
M.insert(0,[*("."*(W+2))])
M.append([*("."*(W+2))])

cnt = 0
Ans = []
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == ".":
            for k in range(-1, 2):
                if M[i+k][j-1] == "#":
                    cnt += 1
                if M[i+k][j] == "#":
                    cnt += 1
                if M[i+k][j+1] == "#":
                    cnt += 1
            print(cnt, end = "")
            cnt = 0
        else:
            print("#", end = "")
    print()
Problem p02742 (python)

Fixed submission:
# 2入力
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
else:
    mass = 0
    if W % 2 != 0:
        if H % 2 != 0:
            mass += (int(H / 2) + 1) * (int(W / 2) + 1)
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)
        else:
            mass += (int(H / 2)) * (int(W / 2) + 1)
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)

    else:
        if H % 2 != 0:
            mass += (int(H / 2) + 1) * (int(W / 2))
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)
        else:
            mass += (int(H / 2)) * (int(W / 2))
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)

Buggy submission (verdict: Runtime Error):
# 2入力
H, W = map(int, input().split())

if H == 1 or W == 1:
    pirnt(1)
else:
    mass = 0
    if W % 2 != 0:
        if H % 2 != 0:
            mass += (int(H / 2) + 1) * (int(W / 2) + 1)
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)
        else:
            mass += (int(H / 2)) * (int(W / 2) + 1)
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)

    else:
        if H % 2 != 0:
            mass += (int(H / 2) + 1) * (int(W / 2))
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)
        else:
            mass += (int(H / 2)) * (int(W / 2))
            mass += (int(H / 2)) * (int(W / 2))
            print(mass)
Problem p02765 (python)

Fixed submission:
N, R = input().split()
N = int(N)
R = int(R)

if N >= 10:
    print(R)
else:
    print(R + 100*(10-N))

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

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

Fixed submission:
N, M = map(int, input().split())
ans = {i:0 for i in range(N+1)}
pn = {i:0 for i in range(N+1)}
ans_num = 0
pn_num = 0

for i in range(M):
    p_tmp, S_tmp = input().split()
    p_tmp = int(p_tmp)
    
    if ans[p_tmp] == 0 and S_tmp == "AC":
        ans[p_tmp] = 1
        ans_num += 1
        pn_num += pn[p_tmp]
        
    elif ans[p_tmp] != 1 and S_tmp == "WA":
        pn[p_tmp] = pn[p_tmp] + 1
        
print(ans_num, pn_num)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = {i:0 for i in range(N)}
pn = {i:0 for i in range(N)}
ans_num = 0
pn_num = 0

for i in range(M):
    p_tmp, S_tmp = input().split()
    p_tmp = int(p_tmp)
    
    if ans[p_tmp] == 0 and S_tmp == "AC":
        ans[p_tmp] = 1
        ans_num += 1
        pn_num += pn[p_tmp]
        
    elif ans[p_tmp] != 1 and S_tmp == "WA":
        pn[p_tmp] = pn[p_tmp] + 1
        
print(ans_num, pn_num)
Problem p02882 (python)

Fixed submission:
import math

a, b, x = map(int, input().split())

if b > 2*x/(a**2):
    print(math.degrees(math.atan(a*b*b/(2*x))))
else:
    print(math.degrees(math.atan((2/a)*(b-(x/(a**2))))))

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

if b > 2*x/(a**2):
    print(math.degrees(math.atan(a*b*b/(2*x))))
else:
    print(math.degrees(math.atan((2/a)*(b-(x/(a**2))))))
Problem p02917 (python)

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

a = []
sum_a = b[0] + b[-1]
for i,b_i in enumerate(b):
    
    if i+1 < n-1:
        if b[i+1] >= b[i]:
            a.append(b[i])
            sum_a += b[i]
        else:
            a.append(b[i+1])
            sum_a += b[i+1]
print(sum_a)

Buggy submission (verdict: Runtime Error):
a = []
sum_a = b[0] + b[-1]
for i,b_i in enumerate(b):
    
    if i+1 < n-1:
        if b[i+1] >= b[i]:
            a.append(b[i])
            sum_a += b[i]
        else:
            a.append(b[i+1])
            sum_a += b[i+1]
print(sum_a)
Problem p02918 (python)

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

sut = 0
a = ""
for i,s in enumerate(b):
    if i < n-1:
        if b[i] == b[i+1]:
            sut += 1
        else:
            a += s
    else:
        a+=s
a

count = len(a)
for i in range(k):
    if count <= 1:
        break
    elif count >= 3:
        sut += 2
        count -= 2
    elif count == 2:
        sut += 1
        break
print(sut)

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

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

S = np.array(list(input()), dtype='U1')
 
x = np.sum(S[1:] == S[:-1])
 
x += 2*K
x = min(x, N-1)
print(x)

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

def syukuyaku(S):
    if len(S) <= 1:
        return S
    res = S[0]
    cnt = 0
    i = 0
    while i < len(S)-1:
        if S[i] == S[i+1]:
            while i < len(S)-1 and S[i] == S[i+1]:
                cnt += 1
                i += 1
        else:
            i += 1
            res += S[i]
    return res, cnt

S_ ,cnt = syukuyaku(S)

if S_.count("L") == S_.count("R"):
    if S_.count("L") <= K:
        print(cnt + S_.count("L")*2)
    else:
        print(cnt + K * 2)
elif S_.count("L") > S_.count("R"):
    if S_.count("L") <= K:
        print(len(S)-1)
    else:
        print(cnt + K * 2)
else:
    if S_.count("R") <= K:
        print(len(S)-1)
    else:
        print(cnt + K * 2)
Problem p04000 (python)

Fixed submission:
H, W, N = input().split(" ")
H, W, N = int(H), int(W), int(N)
A = []
for i in range(N):
    A.append([int(j) for j in input().split(" ")])


import itertools
from collections import defaultdict, Counter

c = defaultdict(int)
for a, b in A:
    # そのセルを含む正方形の中心を記録
    for dx,dy in itertools.product([-1,0,1],repeat = 2):
        aa = a + dx
        bb = b + dy
        if 2 <= aa <= H-1 and 2 <= bb <= W-1:
            c[(aa,bb)] += 1
            
result = Counter(c.values())
result[0] = (H-2)*(W-2) - sum(result.values())
 
for j in range(10):
    print(result[j])

Buggy submission (verdict: Runtime Error):
H, W, N = input().split(" ")
H, W, N = int(H), int(W), int(N)
A = [input().split(" ") for i in range(N)]
A = [[int(l[0])-1, int(l[1])-1] for l in A]


black_num = [0 for i in range(10)]

import numpy as np
field = np.array([np.array([1 if [i, j] in A else 0 for j in range(W)]) for i in range(H)])

for h in range(H - 3 + 1):
    for w in range(W - 3 + 1):
        black_num[np.sum(field[h:h+3].T[w:w+3].T)] += 1
for i in black_num:
    print(i)