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

Fixed submission:
s=input()
w=["dream","dreamer","erase","eraser",""]
while True:
    

    if s[0:5]==w[0]:
        if s[5:7]=="er": #dremaerかeraserかerase
            if s[7]=="a": #erはeraseかeraserのer
                s=s[5:]
            else:
                s=s[7:]
        else:
            s=s[5:]

    elif s[0:5]==w[2]:
        if s[5]=="r": 
            s=s[6:]
        else:
            s=s[5:]
    else:
        print("NO")
        exit()

    if len(s)<=7:
        if s in w:
            print("YES")
            exit()
        else:
            print("NO")
            exit()
    
    #print(s)

Buggy submission (verdict: Runtime Error):
s=input()
w=["dream","dreamer","erase","eraser",""]
while True:
    

    if s[0:5]==w[0]:
        if s[5:7]=="er": #dremaerかeraserかerase
            if s[7]=="a": #erはeraseかeraserのer
                s=s[5:]
            else:
                s=s[7:]
        else:
            s=s[5:]

    elif s[0:5]==w[2]:
        if s[5]=="r": 
            s=s[6:]
        else:
            s=s[5:]
    else:
        print("NO")
        exit()

    if len(s)<=6:
        if s in w:
            print("YES")
            exit()
        else:
            print("NO")
            exit()

    #print(s)

Buggy submission (verdict: Runtime Error):
s=input()
w=["dream","dreamer","erase","eraser"]
while True:
    if len(s)==0:
        print("YES")
        exit()
    if len(s)<=4:
        print("NO")
        exit()
    


    if s[0:5]==w[0]:
        if s[5:7]=="er": #dremaerかeraserかerase
            if s[7]=="a": #erはeraseかeraserのer
                s=s[5:]
            else:
                s=s[7:]
        else:
            s=s[5:]

    elif s[0:5]==w[2]:
        if s[5]=="r": 
            s=s[6:]
        else:
            s=s[5:]
    else:
        print("NO")
        exit()

    if len(s)==0:
        print("YES")
        exit()
    #print(s)

Buggy submission (verdict: Runtime Error):
s=input()
w=["dream","dreamer","erase","eraser"]
while True:
    if s[0:5]==w[0]:
        if s[5:7]=="er": #dremaerかeraserかerase
            if s[7]=="a": #erはeraseかeraserのer
                s=s[5:]
            else:
                s=s[7:]
        else:
            s=s[5:]

    elif s[0:5]==w[2]:
        if s[5]=="r": 
            s=s[6:]
        else:
            s=s[5:]
    else:
        print("NO")
        exit()

    if len(s)==0:
        print("YES")
        exit()
    #print(s)
Problem p04013 (python)

Fixed submission:

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

dp = [[[0 for i in range(4000)]for j in range(51)]for k in range(51)]

# dp[i][j][k] → i枚のうちj枚を選んで 和が kになる組み合わせ
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(3000):
            if dp[i][j][k] != 0:
                dp[i+1][j][k] += dp[i][j][k]    #i枚目を選ばなかった世界線
                dp[i + 1][j + 1][k + nums[i]]  += dp[i][j][k]          #i枚目を選んだ世界線


ans = 0
for j in range(1,N+1):
    ans += dp[N][j][j*A]
print(ans)

Buggy submission (verdict: Runtime Error):

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

dp = [[[0 for i in range(2800)]for j in range(50)]for k in range(50)]

# dp[i][j][k] → i枚のうちj枚を選んで 和が kになる組み合わせ
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(2501):
            if dp[i][j][k] != 0:
                dp[i+1][j][k] += dp[i][j][k]    #i枚目を選ばなかった世界線
                dp[i + 1][j + 1][k + nums[i]]  += dp[i][j][k]          #i枚目を選んだ世界線


ans = 0
for j in range(1,N+1):
    ans += dp[N][j][j*A]
print(ans)
Problem p02972 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
ans=[]
for i in range(N):
    n=N-i
    syou=N//n
    c=0
    for l in range(1,syou):
        aa=n*(l+1)-1
        c=(c+b[aa])%2
    if a[n-1]==0:
        if c==0:
            b[n-1]=0
        else:
            b[n-1]=1
            ans.append(str(n))
    if a[n-1]==1:
        if c==0:
            b[n-1]=1
            ans.append(str(n))
        else:
            b[n-1]=0
print(len(ans))
if len(ans)>1:
    print(' '.join(ans))
if len(ans)==1:
    print(1)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
ans=[]
for i in range(N):
    n=N-i
    syou=N//n
    c=0
    for l in range(1,syou):
        aa=n*(l+1)-1
        c=(c+b[aa])%2
    if a[n-1]==0:
        if c==0:
            b[n-1]=0
        else:
            b[n-1]=1
            ans.append(n)
    if a[n-1]==1:
        if c==0:
            b[n-1]=1
            ans.append(n)
        else:
            b[n-1]=0
print(len(ans))
if len(ans)>1:
    print(' '.join(ans))
if len(ans)==1:
    print(1)
Problem p02983 (python)

Fixed submission:
L,R=(int(x) for x in input().split())
ans=[]
for n in range(2019):
    if L+n>=R:
        break
    for l in range(n+1,2019):
        if L+l>R:
            break
        a=(L+n)%2019
        b=(L+l)%2019
        c=a*b%2019
        ans.append(c)
print(min(ans))

Buggy submission (verdict: Runtime Error):
L,R=(int(x) for x in input().split())
L_mod=L%2019
R_mod=R%2019
if L_mod>=R_mod:
    print(0)
else:
    print(L_mod*(L_mod+1s))
Problem p03080 (python)

Fixed submission:
a=input()
s=list(input())
x=s.count('R')
y=s.count('B')
if x>y:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b=input().split()
s=list(b)
x=s.count('R')
y=s.count('B')
if x>y:
    print('Yes')
else:
    print('No')
Problem p02642 (python)

Fixed submission:
N = int(input())
An = list(map(int, input().split()))
An.sort()
max_n = max(An)
dp = [0] * (max_n + 1)
for i in range(N):
    if dp[An[i]] != 0:
        dp[An[i]] = 2
        continue
    for j in range(1, max_n//An[i] + 1):
        dp[An[i]*j] += 1
ans = 0
for a in An:
    if dp[a] == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import njit
@njit
def main():
    N = int(input())
    An = list(map(int, input().split()))
    ans = 0
    ng = set()
    a_An = np.array(An)
    for i, a in enumerate(An):
        temp = a_An / a
        temp[i] = 0.1
        check = np.where(temp % 1 == 0)
        check = check[0]
        # check = np.delete(check, np.where(check == i))
        # check = check[check != i]
        if len(check) > 0:
            ng = ng | set(check)
    print(N-len(ng))

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

Fixed submission:
from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
    temp = An[i]
    if check[temp-1] == 1:
        dup = temp
        break
    root.append(temp)
    check[temp-1] = 1
    i = temp - 1
    cnt += 1
index = root.index(dup)
if index >= k:
    print(root[k])
elif index == cnt - 1:
    print(dup)
else:
    print(root[(k-index) % (cnt-index) + index])

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np
n, k = map(int, input().split())
An = list(map(int, input().split()))
root = deque([1])
check = np.zeros(n, np.int)
check[0] = 1
i = 0
dup = 1
cnt = 1
for _ in range(n):
    temp = An[i]
    if check[temp-1] == 1:
        dup = temp
        break
    root.append(temp)
    check[temp-1] = 1
    i = temp - 1
    cnt += 1
index = root.index(dup)
if index <= k:
    print(root[k-1])
elif index == cnt - 1:
    print(dup)
else:
    print(root[(k-index) % (cnt-index) + index])
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())
ans = 0
if n < b:
    ans = max(ans, a*n//b)
else:
    ans = max(ans, (a*n)//b)-a*(n//b)
    ans = max(ans, ((a*(b*(n//b)-1))//b)-a*(n//b - 1))
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
if n < b:
    ans = a*n//b
else:
    ans = max(ans, (a*(b*2-1))//b - a)
    li = [1, (1+(n//b))//2, -(-(1+(n//b))//2)]
    for i in li:
        check = (a*(b*(i+1)-1))//b - a*i
        ans = max(ans, check)
    ans = max(ans, (a*n)//b)-a*(n//b)
print(ans)
Problem p02702 (python)

Fixed submission:
s = input()[::-1]
length = len(s)
a = [0] * length
d = [0] * length
ans = [0] * 2019
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

ans_c = [i for i in ans if i != 0]

print(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(len(ans_c))]) / 2) + ans[0])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
S = input()
ans = 0
i = 0
while i < len(S)-3:
    for j in range(i+4, len(S)+1):
        if int(S[i:j]) % 2019 == 0:
            ans += 1
            i += j-5
    i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
# for i in range(len(S)-3):
#     for j in range(i+4, len(S)+1):
#         if int(S[i:j]) % 2019 == 0:
#             ans += 1
# #             break
# print(ans)
i = 0
while i < len(S)-3:
    for j in range(i+4, len(S)+1):
        if int(S[i:j]) % 2019 == 0:
            ans += 1
            i += j-5
    i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
i = 0
while i < len(S)-3:
    for j in range(i+4, len(S)+1):
        if int(S[i:j]) % 2019 == 0:
            ans += 1
            print(S[i:j])
            i += j-5
    i += 1
print(ans)
Problem p02732 (python)

Fixed submission:
from collections import Counter
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += c * (c-1) // 2
for a in An:
    print(cnt - (counter[a] - 1))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.misc import comb
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += comb(c, 2)
for a in An:
    if counter[a] < 3:
        print(0)
    else:
        print(int(cnt - comb(counter[a], 2) + comb(counter[a]-1, 2)))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += comb(c, 2)
for a in An:
    if counter[a] < 3:
        print(0)
    else:
        print(int(cnt - comb(counter[a], 2) + comb(counter[a]-1, 2)))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += comb(c, 2)
for a in An:
    print(int(cnt - comb(counter[a], 2) + comb(counter[a]-1, 2)))
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
possibility = [[], [], []]

for i in range(M):
    for j in range(N):
        if sc[i][0]==j+1:
            possibility[j].append(sc[i][1])

ans = ''
if N > 1:
    for i in range(N):
        if i == 0:
            if (0 in list(set(possibility[i]))) or len(set(possibility[i])) > 1:
                ans = -1
                break
            elif len(possibility[i]) == 0:
                ans += str(1)
                continue
            else:
                ans += str(list(set(possibility[i]))[0])
        else:
            if len(possibility[i]) == 0:
                ans += str(0)
                continue
            elif len(set(possibility[i])) > 1:
                ans = -1
                break
            else:
                ans += str(list(set(possibility[i]))[0])
else:
    if len(set(possibility[0])) > 1:
        ans = -1
    elif len(possibility[0]) == 0:
        ans += str(0)
    else:
        ans += str(list(set(possibility[0]))[0])


print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
possibility = [[], [], []]

for i in range(M):
    for j in range(N):
        if sc[i][0]==j+1:
            possibility[j].append(sc[i][1])
ans = ''
for i in range(N):
    if i == 0:
        if list(set(possibility[i]))[0] == 0:
            ans = -1
            break
        elif possibility[i] == []:
            ans += str(1)
            continue
    if len(possibility[i]) == 0:
        ans += str(0)
        continue
    if len(set(possibility[i])) != 1:
        ans = -1
        break
    ans += str(list(set(possibility[i]))[0])

print(ans)
Problem p02767 (python)

Fixed submission:
import sys

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


def cal(number):
    an = 0
    for X in Xn:
        an += (X - number)**2
    return an

ans = sys.maxsize
for i in range(min(Xn), max(Xn)+1, 1):
    ans = min(ans, cal(i))

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

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


def cal(number):
    ans = 0
    for X in Xn:
        ans += (X - number)**2
    return ans

ans = sys.maxsize
for i in range(Xn[1], Xn[-1], 1):
    ans = min(ans, cal(i))

print(ans)
Problem p02780 (python)

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

pn_t = [0]
for i in range(N):
    pn_t.append(pn[i]+pn_t[i])

l = 0
for i in range(N-K+1):
    l = max(l, pn_t[K+i]-pn_t[i])
ans = (l+K)/2
print(ans)

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

l = sum(pn[:K])
for i in range(N-K+1):
    l = max(l, l+pn[K+i]-pn[i])
ans = (l+K)/2
print(ans)

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

l = sum(pn[:K])
for i in range(N-K+1):
    l = max(l, l+pn[K+1+i]-pn[i])
ans = (l+K)/2
print(ans)

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

l = pn[:K]
for i in range(N-K+1):
    l = max(l, l+pn[K+1+i]-pn[i])
ans = (l+K)/2
print(ans)

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

l = pn[:K]
for i in range(N-K+1):
    l = max(l, l+pn[K+1]-pn[i])
ans = (l+K)/2
print(ans)
Problem p02787 (python)

Fixed submission:
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
max_a = max(a for a, b in ab)
dp = [0]*(H+max_a)
for i in range(1, H+max_a):
    dp[i] = min(dp[i-a]+b for a, b in ab)
print(dp[H])

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

dp = np.full(H+1, np.inf)
dp[0] = 0

for i in range(N):
    a, b = map(int, input().split())
    dp[1:a+1] = np.minimum(dp[1:a+1], b)
    dp[a+1:] = np.minimum(dp[a+1:], dp[:-a+1]+b)
print(int(dp[-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = np.full(H+max_a, np.inf)
dp[:max_a] = 0
for i in range(max_a, H+max_a):
    for a, b in ab:
        dp[i] = min(dp[i], dp[i-a] + b)
print(int(dp[-1]))
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
ps = [input().split() for i in range(M)]

ac = 0
wa = [0 for i in range(N)]
ansed = set()
for psn in ps:
    if psn[1] == 'AC':
        if psn[0] not in ansed:
            ac += 1
            ansed.add(psn[0])
    else:
        if psn[0] not in ansed:
            wa[int(psn[0])-1] += 1
for i in range(N):
    if str(i+1) not in ansed:
        wa[i] = 0

print(ac, sum(wa))

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

ac = 0
wa = []
ansed = []
for psn in ps:
    if psn[1] == 'AC':
        if psn[0] not in ansed:
            ac += 1
            ansed.append(psn[0])
    else:
        if psn[0] not in ansed:
            wa[int(psn[0])-1] += 1
for i in range(N):
    if str(i+1) not in ansed:
        wa[i] = 0

print(ac, sum(wa))
Problem p02823 (python)

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

if (b-a) % 2 == 0:
    ans = (b-a)//2
else:
    if (a-1) < (n-b):
        ans = a+((b-a-1)//2)
    elif (a-1) == (n-b):
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)//2)

print(int(ans))

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

if (b-a) % 2 == 0:
    ans = (b-a)/2
else:
    if (a-1) < (n-b):
        ans = a+((b-a-1)/2)
    elif (a-1) == (n-b):
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)/2)

print(int(ans))

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

if (b-a) % 2 == 0:
    ans = (b-a)/2
else:
    if a-1 = n-b:
        ans = a+((b-a-1)/2)
    elif a-1 == n-b:
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)/2)

print(int(ans))
Problem p02947 (python)

Fixed submission:
from collections import Counter
from scipy.misc import comb
N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]
ans = 0
for count in Counter(s).values():
    ans += comb(count, 2, exact=True)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]
ans = 0
for count in Counter(s).values():
    ans += comb(count, 2, exact=True)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.misc import comb
N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]
ans = 0
for count in Counter(s).values():
    ans += comb(count, 2, exact=True)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from scipy.special import comb
N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]
ans = 0
for count in Counter(s).values():
    ans += comb(count, 2, exact=True)
print(ans)
Problem p02995 (python)

Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
lcm = (c*d)//fractions.gcd(c, d)
a -= 1
ans1 = b - b//c - b//d + b//lcm
ans2 = a - a//c - a//d + a//lcm
print(ans1 - ans2)

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

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
x = 0
ans = 1
for i in range(N):
    x += L[i]
    if x > X:
        break
    else:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
x = 0
i = 0
while x <= X:
    x += L[i]
    i += 1
print(i)
Problem p03076 (python)

Fixed submission:
menu = [int(input()) for _ in range(5)]
ans = 0
mod = []
for time in menu:
    if time % 10 == 0:
        ans += time
    else:
        ans += time
        mod.append(10 - time % 10)
try:
    mod.remove(max(mod))
    ans += sum(mod)
except:
    pass
print(ans)

Buggy submission (verdict: Runtime Error):
menu = [int(input()) for _ in range(5)]
ans = 0
mod = []
for time in menu:
    if time % 10 == 0:
        ans += time
    else:
        ans += time
        mod.append(10 - time % 10)
mod.remove(max(mod))
ans += sum(mod)
print(ans)
Problem p03238 (python)

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

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

Buggy submission (verdict: Runtime Error):
import sys
N = input()
if N == 1:
    print('Hello World')
    sys.exit()
else:
    A, B = map(int, input().split())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N = input()
if N == 1:
    print('Hello World')
    exit()
else:
    A, B = map(int, input().split())
    print(A+B)

Buggy submission (verdict: Runtime Error):
N = input()
if N == 1:
    print('Hello World')
else:
    print(int(input()) + int(input()))
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]


def dfs(i, sum, count, nokori):
    global ans
    if i == D:
        if sum < G:
            use = max(nokori)
            n = min(pc[use-1][0], -(-(G-sum)//(use*100)))
            count += n
            sum += n * use * 100
        if sum >= G:
            ans = min(ans, count)

    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})


ans = float('inf')

dfs(0, 0, 0, set(range(1, D+1)))
print(ans)

Buggy submission (verdict: Runtime Error):
pc = [list(map(int, input().split())) for i in range(D)]


def dfs(i, sum, count, nokori):
    global ans
    if i == D:
        if sum < G:
            use = max(nokori)
            n = min(pc[use-1][0], -(-(G-sum)//(use*100)))
            count += n
            sum += n * use * 100
        if sum >= G:
            ans = min(ans, count)

    else:
        dfs(i+1, sum, count, nokori)
        dfs(i+1, sum+pc[i][0]*(i+1)*100+pc[i][1], count+pc[i][0], nokori-{i+1})


ans = float('inf')

dfs(0, 0, 0, set(range(1, D+1)))
print(ans)
Problem p03477 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('Right')

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('R
Problem p03574 (python)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]
ad = ['.' for _ in range(W)]
S.append(ad)
S.insert(0, ad)
newS = [['#' for _ in range(W)] for _ in range(H)]
for i in range(1, H+1):
    for j in range(W):
        if S[i][j] == '.':
            c = max(0, j-1)
            d = min(W-1, j+1)
            cnt = S[i][c:d+1].count('#')
            cnt += S[i-1][c:d+1].count('#')
            cnt += S[i+1][c:d+1].count('#')
            newS[i-1][j] = str(cnt)
for i in newS:
    print(''.join(i))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input() for _ in range(H)]
newS = [['#' for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            c = max(0, j-1)
            d = min(W-1, j+1)
            if i == 0:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            elif i == H-1:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
            else:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            newS[i][j] = str(cnt)
for i in newS:
    print(''.join(i))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input() for _ in range(H)]
newS = [['#']*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            c = max(0, j-1)
            d = min(W-1, j+1)
            if i == 0:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            elif i == H-1:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
            else:
                cnt = S[i][c:d+1].count('#')
                cnt += S[i-1][c:d+1].count('#')
                cnt += S[i+1][c:d+1].count('#')
            newS[i][j] = str(cnt)
for i in newS:
    print(''.join(i))
Problem p03611 (python)

Fixed submission:
from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)