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

Fixed submission:
# D
import math
n, h = map(int, input().split())
max_a = 0
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if max_a < a[i]:
        max_a = a[i]
throw = []
for i in range(n):
    if b[i] > max_a:
        throw.append(b[i])
throw.sort(reverse=True)
damage = 0
count = 0
for i in range(len(throw)):
    damage += throw[i]
    count += 1
    if damage >= h:
        break
if damage < h:
    count += math.ceil((h - damage) / max_a)
print(count)

Buggy submission (verdict: Runtime Error):
%%test_input https://atcoder.jp/contests/abc085/tasks/abc085_d
# D
import math
n, h = map(int, input().split())
max_a = 0
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if max_a < a[i]:
        max_a = a[i]
throw = []
for i in range(n):
    if b[i] > max_a:
        throw.append(b[i])
throw.sort(reverse=True)
damage = 0
count = 0
for i in range(len(throw)):
    damage += throw[i]
    count += 1
    if damage >= h:
        break
if damage < h:
    count += math.ceil((h - damage) / max_a)
print(count)
Problem p03486 (python)

Fixed submission:
#B
import collections

s = str(input())
t = str(input())
sd = list(s)
td = list(t)
sd.sort()
td.sort(reverse=True)
a = ''
b = ''
for c in sd:
    a += c
for c in td:
    b += c
if sd < td:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
%%test_input https://atcoder.jp/contests/abc082/tasks/abc082_b
#B
import collections

s = str(input())
t = str(input())
sd = list(s)
td = list(t)
sd.sort()
td.sort(reverse=True)
a = ''
b = ''
for c in sd:
    a += c
for c in td:
    b += c
if sd < td:
    print('Yes')
else:
    print('No')
Problem p03494 (python)

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

def calc_half(n):
    return int(n / 2)

all_even = True
count = 0
while all_even:
    for value in a:
        if value % 2 == 1:
            all_even = False
            break
    if all_even:
        a = list(map(calc_half, a))
        count +=1
print(count)

Buggy submission (verdict: Runtime Error):
# B
n = int(input())
a = [int(i) for i in input().split()]
count = 0
flag = True
while flag:
    for i in range(len(a)):
        if a[i] % 2 == 0:
            continue
        else:
            flag  = False
            break
    a = map(lambda x: x / 2, a)
print(count)
Problem p03660 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
from collections import deque

n = int(input())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

def get_dists(f):
    dists = [0 for _ in range(n)]
    q = deque()
    q.append((f, -1, 0))
    while len(q) > 0:
        num, f_num, dist = q.popleft()
        for node in edges[num]:
            if node == f_num:
                continue
            else:
                dists[node] = dist + 1
                q.append((node, num, dist+1))
    return dists

dist_1 = get_dists(0)
dist_n = get_dists(n-1)

ans = 0
for i in range(n):
    if dist_1[i] <= dist_n[i]:
        ans += 1

fennec = ans
snuke = n - fennec
if fennec > snuke:
    print("Fennec")
else:
    print("Snuke")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
from collections import deque

n = int(input())

edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

nodes = [0 for _ in range(n)]
"""
white = all - black
"""

goal = n - 1
def dfs(num, f_num):
    if num == goal:
        nodes[num] = 1
        return 1
    s = 0
    for node in edges[num]:
        if node == f_num:
            continue
        s += dfs(node, num)
    nodes[num] = s + 1
    return s + 1

def dist(start, end):
    q =  deque([(0, -1, 1)])
    res = 0
    while len(q) > 0:
        num, f_num, dist = q.popleft()
        if num == end:
            res = dist
        for node in edges[num]:
            if node == f_num:
                continue
            q.append((node, num, dist + 1))
    return res

dfs(0, -1)
fennec = nodes[0] - dist(0, n-1) // 2
snuke = n - fennec
if fennec > snuke:
    print("Fennec")
else:
    print("Snuke")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

n = int(input())

edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

nodes = [0 for _ in range(n)]
"""
white = all - black
"""

goal = n - 1
def dfs(num, f_num):
    if num == goal:
        nodes[num] = 1
        return 1
    s = 0
    for node in edges[num]:
        if node == f_num:
            continue
        s += dfs(node, num)
    nodes[num] = s + 1
    return s + 1

def dist(start, end):
    q = [(0, -1, 1)]
    res = 0
    while len(q) > 0:
        num, f_num, dist = q.pop()
        print(num, f_num, dist)
        if num == end:
            res = dist
        for node in edges[num]:
            if node == f_num:
                continue
            q.append((node, num, dist + 1))
    return res

dfs(0, -1)
fennec = nodes[0] - dist(0, n-1) // 2
snuke = n - fennec
if fennec > snuke:
    print("Fennec")
else:
    print("Snuke")
Problem p03696 (python)

Fixed submission:
n = int(input())
s = str(input())

ans_s = s
ans_head = 0
ans_tail = 0

def remove(s):
    while True:
        if len(s) <= 0:
            break
        pre_len = len(s)
        s = s.replace("()", "")
        if len(s) == pre_len:
            break
    return s

s = remove(s)
while len(s) > 0:
    s = remove(s)
    if s[0] == ')':
        ans_head += 1
        s = remove('(' + s)
    else:
        ans_tail += 1
        s = remove(s + ')')
    # print(s)
print('('*ans_head + ans_s + ')' * ans_tail)

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

ans_s = s
ans_head = 0
ans_tail = 0

def remove(s):
    while True:
        if len(s) <= 0:
            break
        pre_len = len(s)
        s = s.replace("()", "")
        if len(s) == pre_len:
            break
    return s

while len(s) > 0:
    s = remove(s)
    if s[0] == ')':
        ans_head += 1
        s = remove('(' + s)
    else:
        ans_tail += 1
        s = remove(s + ')')
    # print(s)
print('('*ans_head + ans_s + ')' * ans_tail)

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

ans_s = s
ans_head = 0
ans_tail = 0

def remove(s):
    while True:
        pre_len = len(s)
        s = s.replace("()", "")
        if len(s) == pre_len:
            break
    return s

while len(s) > 0:
    s = remove(s)
    if s[0] == ')':
        ans_head += 1
        s = remove('(' + s)
    else:
        ans_tail += 1
        s = remove(s + ')')
    # print(s)
print('('*ans_head + ans_s + ')' * ans_tail)
Problem p03761 (python)

Fixed submission:
from collections import defaultdict

n = int(input())
s = []
for i in range(n):
    s.append(list(str(input())))

alphabet = set(s[0])

for i in range(1, n):
    alphabet = alphabet & set(s[i])

count_min = defaultdict(lambda: 10**9)
for a in sorted(alphabet):
    for i in range(n):
        count_min[a] = min(count_min[a], s[i].count(a))

ans = ""

for k, v in sorted(count_min.items()):
    for i in range(v):
        ans += k
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
    s.append(list(str(input())))

alphabet = set(s[0])

for i in range(1, n):
    alphabet = alphabet & set(s[i])

count_min = {}
for a in sorted(alphabet):
    count_min[a] = min(count_min[a], s[0].count(a))

ans = ""

for k, v in sorted(count_min.items()):
    for i in range(v):
        ans += k
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
    s.append(list(str(input())))

alphabet = set(s[0])

for i in range(1, n):
    alphabet = alphabet & set(s[i])

count_min = {}
for a in sorted(alphabet):
    count_min[a] = min(s[0].count(a))

ans = ""

for k, v in sorted(count_min.items()):
    for i in range(v):
        ans += k
print(ans)
Problem p03957 (python)

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

f = 0
for i in range(n):
    if s[i] == 'C' and f == 0:
        f += 1
    if s[i] == 'F' and f == 1:
        print("Yes")
        exit()
print("No")

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

f = 0
for i in range(s):
    if s[i] == 'C' and f == 0:
        f += 1
    if s[i] == 'F' and f == 1:
        print("Yes")
        exit()
print("No")

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

f = 0
for i in range(s):
    if s[i] == 'C' and f = 0:
        f += 1
    if s[i] == 'F' and f = 1:
        print("Yes")
        exit()
print("No")
Problem p04013 (python)

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0 for _ in range(n*x_max+1)] for _ in range(n+1)] for _ in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        for k in range(n*x_max+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i >= 1 and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i >= 1 and j >= 1 and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i-1]]
            else:
                dp[i][j][k] = 0
ans = 0
for k in range(1, n+1):
    if k * a <= n*x_max:
        ans += dp[n][k][k*a]
print(ans)

Buggy submission (verdict: Runtime Error):
n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0 for _ in range(n*x_max+1)] for _ in range(n+1)] for _ in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        for k in range(n*x_max+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i >= 1 and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i >= 1 and j >= 1 and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i-1]]
            else:
                dp[i][j][k] = 0
ans = 0
for k in range(n+1):
    ans += dp[n][k][k*a]
print(ans-1)
Problem p04031 (python)

Fixed submission:
from math import ceil
n = int(input())
a = list(map(int, input().split()))

ans = 10**10

m1 = a[int(n/2)]
m2 = int(sum(a) / n)
m3 = ceil(sum(a) / n)

for v in [m1, m2, m3]:
    cost = 0
    for i in range(n):
        cost += (a[i] - v) ** 2
    ans = min(cost, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import ceil
n = int(input())
a = list(map(int, input().split()))

ans = 10**10

m1 = a[ceil(n/2)]
m2 = int(sum(a) / n)
m3 = ceil(sum(a) / n)

for v in [m1, m2, m3]:
    cost = 0
    for i in range(n):
        cost += (a[i] - v) ** 2
    ans = min(cost, ans)
print(ans)
Problem p02765 (python)

Fixed submission:
N, K = map(int, input().split())
a = 0
 
if N < 10:
  a = 100*(10-N) + K
  print(a)
  
elif N >= 10:
  print(K)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input())
a = 0

if N < 10:
  a = 100*(10-N) + K
  print(a)
  
elif N >= 10:
  print(K)
Problem p02882 (python)

Fixed submission:
a, b, x = map(int, input().split())
import math

S = a*b
s = x/a
if s == S:
  print(0)

elif s >= S/2:
  em_s = S-s
  tan = (a**2)/(2*em_s)
  ans = math.degrees(math.atan(tan))
  print(90-ans)

else:
  tan = (2*s)/(b**2)
  ans = math.degrees(math.atan(tan))
  print(90-ans)

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

S = a*b
s = x/a

if s >= S/2:
  em_s = S-s
  tan = (a**2)/(2*em_s)
  ans = math.degrees(math.atan(tan))
  print(90-ans)
else:
  tan = (2*s)/(b**2)
  ans = math.degrees(math.atan(tan))
  print(90-ans)
Problem p02909 (python)

Fixed submission:
S = input()

if S == 'Sunny':
  print('Cloudy')
elif S == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')

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

ans = [K]*N

for i in range(Q):
  A = int(input())
  
  
  for j in range(N):
    if j != (A-1):
      if ans[j] > 0:
        ans[j] -= 1
  

for i in range(N):
  if ans[i] <= 0:
    print('No')
  else:
    print('Yes')
Problem p02993 (python)

Fixed submission:
n = list(input())

if n[0] == n[1]:
  print("Bad")
  exit()
elif n[1] == n[2]:
  print("Bad")
  exit()
elif n[2] == n[3]:
  print("Bad")
  exit()
print('Good')

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

s = n*(l-1) + n*(n+1)/2
c = s
j = 1

for i in range(n):
  t = s - ((l-1)-1)
  T = abs(s-t)
  if T < c:
    c = T
    j = i
    
e = l+j
print(int(s-e))
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
  print('Hello World')
  
elif N == 2:
  print(int(input()) + int(input()))

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

if a[0] == 2:
  print(a[1] + a[2])
  
elif a[0] == 1:
  print('Hello World')

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

if a[0] == 2:
  print(a[1] + a[2])
  
else:
  print('Hello World')

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

N = a[0]
A = a[1]
B = a[2]

if N = 1:
  print("Hello World")
  
elif:
  print(A + B)
Problem p02628 (python)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:k]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=list(map(int,input().split())
p.sort()
print(sum(p[:k]))
Problem p02600 (python)

Fixed submission:
x=int(input())
if x >=400 and 599>=x:
  print("8")
if x >=600 and 799>=x:
  print("7")
if x >=800 and 999>=x:
  print("6")
if x >=1000 and 1199>=x:
  print("5")
if x >=1200 and 1399>=x:
  print("4")
if x >=1400 and 1599>=x:
  print("3")
if x >=1600 and 1799>=x:
  print("2")
if x >=1800:
  print("1")

Buggy submission (verdict: Runtime Error):
x=input()
if x >=400 and 599<=x:
  print("8")
if x >=600 and 799<=x:
  print("7")
if x >=800 and 999<=x:
  print("6")
if x >=1000 and 1199<=x:
  print("5")
if x >=1200 and 1399<=x:
  print("4")
if x >=1400 and 1599<=x:
  print("3")
if x >=1600 and 1799<=x:
  print("2")
if x >=1800 
  print("1")
Problem p02612 (python)

Fixed submission:
N=int(input())
A=N%1000
if A == 0:
    print(A)
    exit()
A=1000-A
print(A)

Buggy submission (verdict: Runtime Error):
N=input()
A=N%1000
print(A)
Problem p02614 (python)

Fixed submission:
H,W,K=map(int,(input().split()))
board=[list(input()) for _ in range(H)]
ans=0
for paint_H in range(2**H):
    for paint_W in range(2**W):
        cnt=0
        for i in range(H):
            for j in range(W):
                if(paint_H>>i)&1==0 and (paint_W>>j)&1==0:
                    if board[i][j]=="#":
                        cnt+=1
        if cnt==K:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
H,W,K=map(int,(input().split()))
board=[list(input().split()) for _ in range(H)]
ans=0
for paint_H in range(2**H):
    for paint_W in range(2**W):
        cnt=0
        for i in range(H):
            for j in range(W):
                if(paint_H>>i)&1==0 and (paint_W>>j)&1==0:
                    if board[i][j]=="#":
                        cnt+=1
        if cnt==K:
            ans+=1
print(ans)
Problem p02657 (python)

Fixed submission:
x,y=map(int,input().split())
print(x*y)

Buggy submission (verdict: Runtime Error):
N=(int(input()))//10
if N==2 or N==4 or N==5 or N==7 or N==9:
  print("hon")
elif N==0 or N==1 or N==6 or N==8:
  print("pon")
else:
  print("bon")

Buggy submission (verdict: Runtime Error):
x=int(input())
y=int(input())
print(x*y)
Problem p02681 (python)

Fixed submission:
S=str(input())
T=str(input())
S_list=list(S)
T_list=list(T)
count=0
for i in range(len(S)):
    if S[i]==T[i]:
        count+=1
if count==len(S_list):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S,T=map(str,input().split())
S_list=list(S)
T_list=list(T)
count=0
for i in range(len(S)):
    if S[i]==T[i]:
        count+=1
if count==len(S_list):
    print("Yes")
else:
    print("No")
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
c=1
t=0
for s in l:
  t+=s
  if t<=x:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
s,x=(int(y) for y in input().split())
l=list(map(int, input().split()))
a=0
c=0
for y in range(s+1):
	if x>=c:
		a+=1
		c+=l[y]
	else:
		break
print(a)
Problem p02613 (python)

Fixed submission:
def main():
    N = int(input())
    AC = 0
    WA = 0
    TLE = 0
    RE = 0
    for i in range(N):
        St = input()
        if St == 'AC':
            AC += 1
        elif St == 'WA':
            WA += 1
        elif St == 'TLE':
            TLE += 1
        elif St == 'RE':
            RE += 1
        else:
            Er += 1
    print('AC x', AC)
    print('WA x', WA)
    print('TLE x', TLE)
    print('RE x', RE)
main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    AC = 0
    WA = 0
    TLE = 0
    RE = 0
    for i in range(N):
        St = input()
        if St == 'AC':
            AC += 1
        elif St == 'WA':
            WA += 1
        elif St == 'TLE':
            TLE += 1
        elif St == 'RE':
            RE += 1
        else:

    print('AC x ' + str(AC))
    print('AC x ' + str(WA))
    print('AC x ' + str(TLE))
    print('AC x ' + str(RE))
main()
Problem p02582 (python)

Fixed submission:
s = input()

if s.count("R") in [0,1,3]:
  print( s.count("R") )
else:
  if s == "RSR":
    print(1)
  else:
    print(2)

Buggy submission (verdict: Runtime Error):
X, K, D = map( int, input().split())
 
Y = X // D
if K <= Y:
  print( min( abs( X - K * D ) , abs( X + K * D ) ))
else:
  if ( K - Y ) % 2 == 0:
    print( min( abs( X - Y * D ) , abs( X + Y * D ) ),
           min( abs( X - ( Y - 2 ) * D ), abs( X - ( Y + 2 ) * D ),
                abs( X + ( Y - 2 ) * D ), abs( X + ( Y + 2 ) * D )) )
  else:
    print( min( abs( X - ( Y - 1 ) * D ), abs( X - ( Y + 1 ) * D ),
                abs( X + ( Y - 1 ) * D ), abs( X + ( Y + 1 ) * D )) )
Problem p02628 (python)

Fixed submission:
N, K = map( int, input().split() )
 
p = sorted( list( map( int, input().split() ) ) )
 
print( sum( p[ : K ] ) )

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

p = sorted( list( map( int, input().split() ) ) )

print( sum( p[ : K ] ) )
Problem p02658 (python)

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

if 0 in A:
  print( 0 )
else:
  ret = 1
  for a in A:
    ret = ret * a
    if ret > 10 ** 18:
      ret = -1
      break
  print( ret )

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

if 0 in A:
  print( 0 )
else:
  ret = 1
  for a in A:
    ret *= a
    if ret > 10 ** 18:
      ret = -1
      break
  print( ret )

Buggy submission (verdict: Runtime Error):
n = int( input() )
A = list( int, input().split() )

ret = 1
for a in A:
  ret *= a
  if a == 0:
    ret = 0
    break
  if a > 10 ** 18:
    ret = -1
    break
print( ret )
Problem p02660 (python)

Fixed submission:
n = int( input())
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, cnt])

    if temp!=1:
        arr.append([temp, 1])

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

    return arr
fact = factorization( n )

cnt = 0
for f in fact:
  if f[0] == 1:
    continue
  fa = f[ 1 ]
  fa -= 1
  i = 2
  while fa >= 0:
    cnt += 1
    fa -= i
    i += 1
print( cnt )

Buggy submission (verdict: Runtime Error):
n = int( input() )
A = []
B = []

for i in range( n ):
  a, b = map( int, input().split() )
  A.append( a )
  B.append( b )

A = sorted( A )
B = sorted( B )

if n % 2 == 0:
  i = n // 2
  print(( B[ i ] + B[ i - 1 ] ) - ( A[ i ] + A [ i - 1 ] ) + 1 )
else:
  i = ( n + 1 ) // 2 - 1
  print( B[ i ] - A[ i ] + 1 )
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if S == T[:len(S)]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B, C, K = map( int, input().split())
ret = min( A, K )
if A < K:
  ret -= max( 0, K - A - B )
print( ret )

Buggy submission (verdict: Runtime Error):
S, T = input().split()

if S == T[:len(S)]:
  print("Yes")
else:
  print("No")
Problem p02768 (python)

Fixed submission:
N, A, B = map( int, input().split() )
MOD = 10 ** 9 + 7

def comb( n, r ):
  c = 1
  m = 1
  r = min( r, n - r )
  for i in range( r ):
    c = ( c * ( n - i )) % MOD
    m = ( m * ( i + 1 )) % MOD 
  return c * pow( m, MOD - 2, MOD ) % MOD

n = pow( 2, N, MOD ) - 1
a = comb( N, A )
b = comb( N, B )
print(( n - a - b ) % MOD )

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

mod = 10 ** 9 + 7

def comb( n, r, mod ):
  c = 1
  m = 1
  r = min( n - r, r )
  for i in range( r ):
    c = c * ( n - i ) % mod
    m = m * ( i + 1 ) % mod
  return c * pow( m, mod - 2, mod ) % mod

N = pow( 2, n, mod )
A = comb( n, a )
B = comb( n, b )
print(( N - A - B ) % mod )
Problem p02801 (python)

Fixed submission:
s = "abcdefghijklmnopqrstuvwxyz"
C = input()
for i in range(len(s)):
  if(s[i] == C):
    print(s[i+1])

Buggy submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
X = [input() for _ in range(H)]
maxloc = -10

def bfs(sx, sy, gx, gy):
  if(X[sx-1][sy-1] == '#' or X[gx-1][gy-1] == '#'):
    return -1
  else:
    dist = [[-1]*W for _ in range(H)]
    dist[sx-1][sy-1] = 0
    q = deque([(sx-1, sy-1)])
    while q:
      u, v = q.popleft()
      for i, j in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        if not(0 <= u+i < H and 0 <= v+j < W):
          continue
    
        if(dist[u+i][v+j] >= 0 or X[u+i][v+j] == "#"):
          continue

        dist[u+i][v+j] = dist[u][v]+1
        q.append((u+i, v+j))

    return dist[gx-1][gy-1]

for i in range(H):
  for j in range(W):
    sx = i
    sy = j
    for k in range(i+1, H):
      for l in range(j+1, W):
        gx = k
        gy = l
        if(bfs(i+1, j+1, k+1, l+1) > maxloc):
          maxloc = bfs(i+1, j+1, k+1, l+1)
          
print(maxloc)
Problem p02803 (python)

Fixed submission:
def main():
  from collections import deque
  H, W = map(int, input().split())
  graph = [['#'] * (W+2) for _ in range(H+2)]
  for i in range(H):
    S = input()
    for j in range(W):
      graph[i+1][j+1] = S[j]

  def dfs(sx, sy):
    q = deque([(sx, sy)])
    dist = [[-1] * (W+2) for _ in range(H+2)]
    dist[sx][sy] = 0
    s = 0
    while q:
      x, y = q.popleft()
      dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
      for dx, dy in dxy:
        nextx = x+dx
        nexty = y+dy
        if(dist[nextx][nexty] >= 0):
          continue
        if(graph[nextx][nexty] == '#'):
          continue
        dist[nextx][nexty] = dist[x][y] + 1
        q.append((nextx, nexty))
    for i in range(H+2):
      for j in range(W+2):
        if(dist[i][j] >= 0):
          s = max(s, dist[i][j])
    return s

  ans = 0  
  for sx in range(1, H+1):
    for sy in range(1, W+1):
      if(graph[sx][sy] == '.'):
          tmp = dfs(sx, sy)
          ans = max(ans, tmp)
          
  print(ans)
  
main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import math
maxloc = -10
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
for y in range(h):
    for x in range(w):
        if maze[y][x]=='.':
            maze[y][x]=1000000

for i in range(h):
  for j in range(w):
    sy = i
    sx = j
    if(maze[sy-1][sx-1] != '#'):
      maze[sy-1][sx-1]=0
      for k in range(h):
        for l in range(w):
          gy = k
          gx = l
          if(maze[gy-1][gx-1] != '#'):
            que = deque([[sy-1, sx-1]])
            while que:
              y, x = que.popleft()
              for i, j in [(1,0),(0,1),(-1,0),(0,-1)]:
                nexty, nextx = y+i, x+j
                dist = maze[nexty][nextx]
                if(dist != '#'):
                  if dist > maze[y][x]+1:
                    maze[nexty][nextx] = maze[y][x]+1
                    que.append([nexty, nextx])
            if(int(maze[gy-1][gx-1])>maxloc):
              maxloc = maze[gy-1][gx-1]
            
print(maxloc)