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

Fixed submission:
s=input()
import re
ans=re.findall("[A,T,G,C]+",s)#findall、なかったら[]が帰ってくる。matchのようにNoneが帰ってくるわけではない。
if ans==[]:
    print(0)
else:
    print(len(max(ans,key=len)))#このときfindallで返される行列は先頭から見つかったもの順に並べられることに注意すること。

Buggy submission (verdict: Runtime Error):
s =input()
ans = re.finditer(r'(A|T|G|C)+',s)
max=0
for a in ans:
    temp=len(a.group())
    if temp>=max:
        max=temp
print(max)
Problem p02687 (python)

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

Buggy submission (verdict: Runtime Error):
S = input()
if S == "ABC:
	print("ARC")
else:
  print("ABC")
Problem p02718 (python)

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

a.sort(reverse=True)
b=sum(a)/4/m
if a[m-1]<b:
    print('No')
else:
    print('Yes')

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

a.sort(reverse=True)
b=sum(a)/4/m
print(a)
print(a[m])
if a[m-1]<b:
    print('No')
else:
    print('Yes')

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

a.sort(reverse=True)

if a[m]<sum(a)/4/m:
    print('No')
else:
    print('Yes')
Problem p02730 (python)

Fixed submission:
s=list(map(str, input()))
s_=s.copy()
s.reverse()
a=s_[:int((len(s_)-1)/2)]
a_=a.copy()
a.reverse()
b=s_[int((len(s_)+3)/2)-1:]
b_=b.copy()
b.reverse()
if s_==s and a_==a and b_==b:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=list(map(str, input()))
s_=s.copy()
s.reverse()
a=s_[:int((len(s_)-1)/2)]
a_=a.copy()
a.reverse()
b=s_[int((len(s_)+3)/2)-1:]
b_=b.copy()
b.reverse()
if s_==s and a_==a and b_==b:
    print('Yes')
else:
    print('No')
Problem p02756 (python)

Fixed submission:
from collections import deque
s=deque(input())
n=int(input())
r=0
for i in range(n):
    strlist=input()
    if strlist[0]=='1':
        r+=1
    elif strlist[0]=='2' and strlist[2] == '1':
        if r%2==0:
            s.appendleft(strlist[4])
        else:
            s.append(strlist[4])
    elif strlist[0]=='2' and strlist[2] =='2':
        if r%2==0:
            s.append(strlist[4])
        else:
            s.appendleft(strlist[4])
if r%2==0:
    for s_ in s:
        print(s_, end='')
else:
    s.reverse()
    for s_ in s:
        print(s_, end='')

Buggy submission (verdict: Runtime Error):
from collections import deque
s=deque(input())
n=int(input())
r=0
for i in range(n):
    strlist=input()
    if strlist[0]=='1':
        r+=1
    elif strlist[0]=='2' and strlist[2] == '1':
        if r%2==0:
            s.appendleft(strlist[4])
        else:
            s.append(strlist[4])
    elif strlist[0]=='2' and strlist[2] =='2':
        if r%2==0:
            s.append(strlist[4])
        else:
            s.appendleft(strlist[4])
if r%2==0:
    for s_ in s:
        print(s_, end='')
else:
    for s_ in s.reverse():
        print(s_, end='')

Buggy submission (verdict: Runtime Error):
from collections import deque
s=deque(input())
n=int(input())
r=0
for i in range(n):
    strlist=input()
    if strlist[0]=='1':
        r+=1
    elif strlist[0]=='2' and strlist[2] == '1':
        if r%2==0:
            s.appendleft(strlist[4])
        else:
            s.append(strlist[4])
    else:
        if r%2==0:
            s.append(strlist[4])
        else:
            s.appendleft(strlist[4])
if r%2==0:
    for s_ in s:
        print(s_, end='')
else:
    for s_ in s[::-1]:
        print(s_, end='')

Buggy submission (verdict: Runtime Error):
s=input()
n=int(input())
strlist=[input() for i in range(n)]
for i in range(n):
  if i==1:
    s=s[::-1]
  elif i==2 and strlist[i][2] == 1:
    s = '{}{}'.format(strlist[i][4],s)
  elif i==2 and strlist[i][2] == 2:
    s = '{}{}'.format(s,strlist[i][4])
print(s)
Problem p02760 (python)

Fixed submission:
a = [list(map(int, input().split())) for i in range(3)]
output =[[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
check=False
for k in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                output[i][j]=1
for i in range(3):
    if output[i][0]*output[i][1]*output[i][2]==1:
        check=True
    elif output[0][i]*output[1][i]*output[2][i]==1:
        check=True
if output[0][0]*output[1][1]*output[2][2]==1:
    check=True
elif output[2][0]*output[1][1]*output[0][2]==1:
    check=True
if check==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
output =[[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
check==False
for k in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                output[i][j]=1
for i in range(3):
    if output[i][0]*output[i][1]*output[i][2]==1:
        check=True
    elif output[0][i]*output[1][i]*output[2][i]==1:
        check=True
if output[0][0]*output[1][1]*output[2][2]==1:
    check=True
elif output[2][0]*output[1][1]*output[0][2]==1:
    check=True
if check==True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
output =[[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for k in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                output[i][j]=1
for i in range(3):
    if output[i][0]*output[i][1]*output[i][2]==1:
        check=True
    elif output[0][i]*output[1][i]*output[2][i]==1:
        check=True
if output[0][0]*output[1][1]*output[2][2]==1:
    check=True
elif output[2][0]*output[1][1]*output[0][2]==1:
    check=True
if check==True:
    print('Yes')
else:
    print('No')
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
l=[-1]*n
check=False

for i in range(m):
    s,c=map(int,input().split())
    if n!=1 and s==1 and c==0:
        break
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        break
    if i==m-1:
        check=True
if n!=1 and l[0]==-1:
    l[0]=1

if m!=0 and check:
    for num in l:
        if num==-1:
            print(0,end='')
        else:
            print(num,end='')
elif n==1 and m==0:
    print(0)
elif m==0:
    print(10**(n-1))
else:
    print('-1')

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split()))
strlist=[input() for i in range(n[1])]
for i in range(10**(n[0]-1),10**n[0]):
    for j in range(n[1]):
        if len(str(i))<int(strlist[j][0]) or str(i)[int(strlist[j][0])-1]!=strlist[j][2]:
            z=1
            break
    if z==1:
        continue
    elif j+1==n[1]:
        print(i)
        break
    else:
        continue
if i==10**n[0]-1:
    print('-1')
Problem p02795 (python)

Fixed submission:
h=int(input())
w=int(input())
n=int(input())

m=max(h,w)
if n%m==0:
  print(int(n/m))
else:
  print(int(n/m+1))

Buggy submission (verdict: Runtime Error):
h=int(input())
w=int(input())
n=int(input())
s=[[h*w for i in range(h)] for j in range(w)]
li=[]
for i in range(w):
  for j in range(h):
    s[i][j]=w*i+h*j-i*j
    if s[i][j]>=n:
      li.append(i+j)
print(min(li))

Buggy submission (verdict: Runtime Error):
h=int(input())
w=int(input())
n=int(input())
s=[[n for i in range(h)] for j in range(w)]
li=[]
for i in range(w):
  for j in range(h):
    s[i][j]=w*i+h*j-i*j
    if s[i][j]>=n:
      li.append(i+j)
print(min(li))
Problem p02658 (python)

Fixed submission:
import sys

N = int(input())
AList = input().split()

result = 1

if "0" in AList:
    print(0)
    sys.exit()
    
for element in AList:
    result = result * int(element)

    if result > 1e+18:
        print(-1)
        sys.exit()

print(result)

Buggy submission (verdict: Runtime Error):
import decimal

N = int(input())

AList = [decimal.Decimal(element) for element in input().split(" ")]

result = 1

for element in AList:
    result += result * element

if result > 10 ** 18:
    print("-1")
else:
    print(result)

Buggy submission (verdict: Runtime Error):
import decimal

N = int(input())
AList = [decimal.Decimal(element) for element in input().split(" ")]
result = 1

for element in AList:
    result *= element

if result > 10 ** 18:
    print("-1")
else:
    print(result)

Buggy submission (verdict: Runtime Error):
import decimal

N = int(input())
AList = [decimal.Decimal(element) for element in input().split(" ")]
result = 1

for element in AList:
    result *= element

if result > 10 ** 18:
    print("-1")
else:
    print(result)
Problem p03005 (python)

Fixed submission:
import sys

def main():
    inputData = input().strip().split(" ")
    result = 0
    ball = int(inputData[0])
    people = int(inputData[1])

    if people <= 1:
        return 0

    if ball > people:
        result = ball - people
        result += 1

    else:
        return 0

    result -= 1

    return result


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main(argv):
    result = 0
    ball = int(argv[0])
    people = int(argv[1])

    if people <= 1:
        return 0

    if ball > people:
        result = ball - people
        result += 1
        
    else:
        return 0

    result -= 1

    return result


if __name__ == '__main__':
    print(main(sys.argv[1:]))
Problem p02789 (python)

Fixed submission:
n,m = map(int,input().split())
if n == m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
if n == m;
    print(Yes)
else:
    print(No)
Problem p02823 (python)

Fixed submission:
N,A,B = map(int,input().split())
temp = 0
if (B-A)%2 == 0:
    print(int((B-A)//2))
else:
    a = N - A + 1
    b = N - B + 1
    print(min([B-1,N-A,A + (B-A-1)//2,a + (b-a-1)//2]))

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
temp = 0
if (B-A)%2 == 0:
    print(int((B-A)/2))
else:
    min = min([B-1,N-A])
    if A-1 < N-B and (B-A-1)% 2 == 0:
        temp = A + (B-A-1)/2
        if temp < min:
            print(temp)
    elif (b-a-1)%2 == 0:
        a = N - A + 1
        b = N - B + 1
        temp = a + (b-a-1)/2
        if temp < min:
            print(temp)
    else:
        print(temp)
Problem p04043 (python)

Fixed submission:
x = str(input())
if x.count("5")==2 and x.count("7")==1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
x = str(input())
if count(x,"5")==2 and count(x,"7")==1:
  print("YES")
else:
  print("NO")
Problem p02641 (python)

Fixed submission:
from sys import stdin

A = list(map(int,stdin.readline().split()))
B = list(map(int,stdin.readline().split()))
C = [x for x in range(-10,110)]
C = set(C)
B = set(B)
C = C.difference(B)
C = list(C)
X=A[0]
N=A[1]
record=200
number=1000
K=0

if N==0:
    print(X)
    K=1

for t in C:
    diff=abs(t-X)
    if diff<record:
        record=diff
        number=t
    elif diff==record:
        number=min(number,t)

if K==0:
   print(number)

Buggy submission (verdict: Runtime Error):
from sys import stdin

A = list(map(int,stdin.readline().split()))
B = list(map(int,stdin.readline().split()))
C = [x for x in range(1,101)]
C = set(C)
B = set(B)
C = C.difference(B)
C = list(C)
X=A[0]
N=A[1]
record=max(C)
number=0

for t in C:
    diff=abs(t-X)
    if diff<record:
        record=diff
        number=t
    elif diff==record:
        number=min(number,t)

print(number)
Problem p02665 (python)

Fixed submission:
from sys import stdin

a=int(stdin.readline())
A=stdin.readline().split()
sum=0
for k in range(0,a+1):
    sum+=int(A[k])

sum-=int(A[a])
ver=1
lay=1
K=0
T=0

if a==0:
    if A[0]!='1':
        print(-1)
        K=1
    else:
        print(1)
        K=1

for l in range(0,a):
    if lay-int(A[l])<=0:
        print(-1)
        K=1
        break
    if (lay-int(A[l]))*2<int(A[a]) and l==(a-1):
        print(-1)
        K=1
        break
    if (lay-int(A[l]))*2-sum+int(A[l])<=int(A[a]):
        lay=(lay-int(A[l]))*2
        ver+=lay
        sum-=int(A[l])
        T=l
    else:
        lay-=int(A[l])
        sum-=int(A[l])
        x=lay-sum-int(A[a])
        if x==0:
           ver+=lay
        elif x>0:
            print(-1)
            K=1
        else:
           lay=sum+int(A[a])
           ver+=lay
        T=l
        break

if K==0:
    for u in range(T+1,a):
        lay -= int(A[u])
        sum -= int(A[u])
        ver+=lay

if K==0:
    print(ver)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math
a=int(stdin.readline())
A=stdin.readline().split()
sum=0
for k in range(0,a+1):
    sum+=int(A[k])

sum-=int(A[a])
ver=1
lay=1
K=0

for l in range(0,a):
    if lay-int(A[l])<=0:
        print(-1)
        K=1
        break
    if (lay-int(A[l]))*2-sum+int(A[l])<=int(A[a]):
        lay=(lay-int(A[l]))*2
        ver+=lay
        sum-=int(A[l])
        T=l
    else:
        lay-=int(A[l])
        sum-=int(A[l])
        x=lay-sum-int(A[a])
        if x==0:
           ver+=lay
        else:
           lay=sum+int(A[a])
           ver+=lay
        T=l
        break

if K==0:
    for u in range(T+1,a):
        lay -= int(A[u])
        sum -= int(A[u])
        ver+=lay

if K==0:
    print(ver)
Problem p02755 (python)

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

A = list(range(math.ceil((a / 0.08)),int((a+1)/0.08)))
B = list(range(int((b / 0.1)),int((b+1)/0.1)-1))
price = set(A) & set(B)
if len(price) == 0:
    ans = -1
else:
    ans = min(price)
print(ans)

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

A = list(range(int((a / 0.08)),int((a+1)/0.08))-1)
B = list(range(int((b / 0.1)),int((b+1)/0.1))-1)
price = set(A) & set(B)
if len(price) == 0:
    ans = -1
else:
    ans = min(price)
print(ans)
Problem p02642 (python)

Fixed submission:
"""
考え方のポイント
・自分以外では割り切れないような数の個数を求める
　→ 数列の各項に対して〇（割り切れない）×がついていって、〇の個数を数える
・[2, 2]みたいな入力は、他の数で割り切れるようになるので、同じ数が入っていると絶対に×になる。

まずは入力が全部異なる前提で進める。
範囲内の整数からなる全て配列dを用意する。
→ 入力の数列を約数としてもつ数にチェックをしていく（Anに2が含まれていれば、2の倍数全てにチェック（+1)する）
→ チェック後にd[i]をみたとき、d[i]の約数がan中に何個存在するかが示されていることになる。（2∈Aiならd[5](=6)の値は必ず1以上になってる)
"""
N = int(input())
An = [int(i) for i in input().split()]
An.sort()
max_val = 10**6+1
d = [0] * max_val


# O(N) = O(2*10^5)
# d[i]のうち、配列の値の位置を+1しとく。
for i in An:
    d[i] += 1
    # O(MlogM) = 6*10^6
    # 始めてその倍数がきたときだけ
    if(d[i] == 1):
        # [2, 2]などの重複がない場合（既にカウントされているものではない場合)
        # 倍数の位置にも2としておいて以降はみないようにする
        for val in range(i*2, max_val, i):
            d[val] = 2

print(d.count(1))

Buggy submission (verdict: Runtime Error):
N = int(input())
An = [int(_) for _ in input().split()]
An.sort()

old_val = 0
ans = 0
same_flag = False
# 割り切れるものの数を数える
def dfs(An):
    global ans, old_val, same_flag
    if(len(An) == 0):
        return
    val = An.pop(-1)
    # 同じ数に対してのループの場合
    if(val == old_val):
        same_flag = True
    if((same_flag == True) and (val != old_val or len(An) == 1)):
        ans += 1
        same_flag = False
    for i in An:
        # 割り切れる場合はansに数を足して今のループを抜ける
        if(val % i == 0):
            ans += 1
            break
    old_val = val
    # どの数でも割り切れなかった場合は一度抜ける
    dfs(An)

dfs(An)
print(N - ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
An = [int(_) for _ in input().split()]
An.sort()
An = list(set(An))
N = len(An)

ans = 0

# 割り切れるものの数を数える
def dfs(An):
    global ans
    if(len(An) == 0):
        return
    val = An.pop(-1)
    for i in An:
        # 割り切れる場合はansに数を足して今のループを抜ける
        if(val % i == 0):
            ans += 1
            break
    # どの数でも割り切れなかった場合は一度抜ける
    dfs(An)

dfs(An)
if(N == 1):
    last_ans = 0
else:
    last_ans = N - ans

print(last_ans)
Problem p02724 (python)

Fixed submission:
X = int(input(""))

happy_1 = (X // 500) * 1000
happy_2 = ((X % 500) // 5) * 5

val = happy_1 + happy_2

print(val)

Buggy submission (verdict: Runtime Error):
X = input()
uresisa_500yen = (X // 500) * 1000
mod = (X % 500)
uresisa_5yen = (mod // 5) * 5

uresisa_total = uresisa_500yen + uresisa_5yen
print(uresisa_total)
Problem p02641 (python)

Fixed submission:
from bisect import bisect_left
X, N = map(int, input().split())
P = sorted(list(map(int, input().split())))
i = 0
if N == 0:
  print(X)
else:
  while True:
    x = X-i
    idx = bisect_left(P, x)
    if idx < 0 or idx >= N or P[idx] != x:
      print(x)
      break
    else:
      x = X+i
      idx = bisect_left(P, x)
      if idx < 0 or idx >= N or P[idx] != x:
        print(x)
        break
    i += 1

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
X, N = map(int, input().split())
P = sorted(list(map(int, input().split())))
i = 0
if N == 0:
  print(X)
else:
  while True:
    x = X-i
    idx = bisect_left(P, x)
    if idx < 0 or idx >= N or P[idx] != x:
      print(x)
      break
    else:
      x = X+i
      idx = bisect_left(P, x)
      if idx < 0 and idx >= N or P[idx] != x:
        print(x)
        break
    i += 1
Problem p02665 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
isOK = True
B = [0]*(N+1)
B[0] = 1-A[0]
M = 1
i = 1
while i <= N:
  B[i] = B[i-1]*2-A[i]
  i += 1
if B[-1] < 0 or N > 0 and A[-1] == 0:
  isOK = False
B[-1] = A[-1]
i = N-1
while i >= 0:
  if B[i] < 1 or i > 0 and B[i] > B[i-1]*2:
    isOK = False
    break
  else:
    B[i] = min(B[i], B[i+1])+A[i]
  i -= 1
print(-1 if not isOK else sum(B))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
isOK = True
B = [0]*(N+1)
B[0] = 1-A[0]
M = 1
i = 1
while i <= N:
  B[i] = B[i-1]*2-A[i]
  i += 1
if B[i] < 0 or N > 0 and A[-1] == 0:
  isOK = False
B[-1] = A[-1]
i = N-1
while i >= 0:
  if B[i] < 1 or i > 0 and B[i] > B[i-1]*2:
    isOK = False
    break
  else:
    B[i] = min(B[i], B[i+1])+A[i]
  i -= 1
print(-1 if not isOK else sum(B))
Problem p02702 (python)

Fixed submission:
S = input()
if len(S) < 4:
  print(0)
else:
  N = len(S)
  x = 0
  d = [0]*2019
  d[0] = 1
  for i, s in enumerate(reversed(S)):
    x = (x+int(s)*pow(10,i,2019))%2019
    d[x] += 1
  print(sum([m*(m-1)//2 for m in d]))

Buggy submission (verdict: Runtime Error):
from collections import deque
from bisect import bisect

S = input()
if len(S) < 4:
  print(0)
else:
  ans = 0
  d = [deque() for _ in range(3)]
  x = 0
  d[x].append(0)
  for i, s in enumerate(S):
    x = (x+int(s))%3
    d[x].append(i+1)
  for m in range(3):
    for s in d[m]:
      eidx = bisect(d[m], s+4)
      while eidx < len(d[m]):
        e = d[m][eidx]
        ans += 1 if int(S[s:e])%2019 == 0 else 0
        eidx += 1
print(ans)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)[:X]
Q = sorted(list(map(int, input().split())), reverse=True)[:Y]
R = sorted(list(map(int, input().split())), reverse=True)
print(sum(sorted(P+Q+R, reverse=True)[:X+Y]))

Buggy submission (verdict: Runtime Error):
from collections import deque
X, Y, A, B, C = map(int, input().split())
P = deque(sorted(list(map(int, input().split())), reverse=True))
Q = deque(sorted(list(map(int, input().split())), reverse=True))
R = deque(sorted(list(map(int, input().split())), reverse=True))
ans = 0
p_cnt = 0
while p_cnt < X:
  if P[0] < R[0]:
    r = R.popleft()
  else:
    r = P.popleft()
  ans += r
  p_cnt += 1
q_cnt = 0
while q_cnt < Y:
  if Q[0] < R[0]:
    g = R.popleft()
  else:
    g = Q.popleft()
  ans += g
  q_cnt += 1
print(ans)
Problem p02783 (python)

Fixed submission:
H, A = map(int, input().split())
print(H//A + (0 if H%A == 0 else 1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
memo = [10**10]*(H+1)
memo[0] = 0
i = 0
while i <= H:
  for a, b in AB:
    memo[i] = min(memo[i], b+memo[max(0, i-a)])
  i += 1
print(memo[H])
Problem p02801 (python)

Fixed submission:
alphabet = list("abcdefghijklmnopqrstuvwxyz")
s = input()
print(alphabet[alphabet.index(s)+1])

Buggy submission (verdict: Runtime Error):
from collections import deque
import copy
def solve(maze, start, end):
  memo = []
  q = deque()
  q.append([start,[]])
  ans = 0
  while q:
    cur, path = q.popleft()
    if cur == end:
      ans = path
      break
    elif cur in memo:
      continue
    else:
      memo.append(cur)
      for y, x in zip((0,0,1,-1),(1,-1,0,0)):
        if maze[cur[0]+y][cur[1]+x] == ".":
          q.append([[cur[0]+y,cur[1]+x],copy.deepcopy(path)+[cur]])
  return ans


H, W = map(int, input().split())
Maze = [["#"]*(W+2)]+[["#"]+list(input())+["#"] for _ in range(H)] + [["#"]*(W+2)]
Ans = 0
for sy in range(1, H+1):
  for sx in range(1, W+1):
    if Maze[sy][sx] == "#":
      continue
    memo = [[False]*(W+2) for _ in range(H+2)]
    for ey in range(H+1, sy,-1):
      for ex in range(1, W+1):
        if Maze[ey][ex] == "#" or memo[ey][ex]:
          continue
        P = solve(Maze, [sy, sx], [ey,ex])
        Ans = max(Ans, len(P))
        for p in P:
          memo[p[0]][p[1]] = True
print(Ans)
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()
ans = 0
if N > 3:
  for i in range(N-2):
    if S[i:i+3] == "ABC":
      ans += 1
else:
  ans = 1 if S == "ABC" else 0
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
if N > 3:
  for i in range(N-3):
  	if S[i:i+3] == "ABC":
    	ans += 1
else:
  ans = 1 if S == "ABC" else 0
print(ans)
Problem p02848 (python)

Fixed submission:
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = int(input())
S = list(input())
ans = ""
for s in S:
  i = (a.index(s)+N)%26
  ans += a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = input()
S = list(input())
ans = ""
for s in S:
  i = (a.index(s)+N)%26
  ans += a[i]
print(ans)
Problem p02882 (python)

Fixed submission:
import math

a, b, x = map(int, input().split())
t1 = x * (2/(a*(b**2)))
if t1 < (a/b):
  print(90.-math.degrees(math.atan(t1)))
else:
  tmp = 2 * b - x * (2/(a**2))
  if tmp < 0.000001:
    print(0.)
  else:
    t2 = a/(2 * b - x * (2/(a**2)))
    print(90.-math.degrees(math.atan(t2)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())
t1 = x * (2/(a*(b**2)))
t2 = a/(2 * b - x * (2/(a**2)))
if t1 < (a/b):
  print(90.-math.degrees(math.atan(t1)))
else:
  print(90.-math.degrees(math.atan(t2)))
Problem p02903 (python)

Fixed submission:
H, W, A, B = map(int, input().split())
for _ in range(B):
  print("0"*A+"1"*(W-A))
for _ in range(H-B):
  print("1"*A+"0"*(W-A))

Buggy submission (verdict: Runtime Error):
H, W, A, B = map(int, input().split())
ans = [[0]*W for _ in range(H)]
X = [0]*W
fail = False
if H == 1 and B == 0:
  print("1"*A+"0"*(W-A))
elif W == 1 and A == 0:
  for _ in range(B):
    print(1)
  for _ in range(H-B):
    print(0)
else:
  for i in range(H):
    s = 0
    while X[s] >= B:
      s += 1
    c = 0
    while s < W and c < A:
      ans[i][s] = 1
      X[s] += 1
      s += 1
      c += 1
    if c < A:
      fail = True
      break
  print("\n".join(["".join([str(x) for x in a]) for a in ans]) if not fail else "No")
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):
S = input()
if S == "Sunny":
  print("Cloudy")
elif S == "Cloudy"
	print("Rainy")
else:
  print("Sunny")
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(3*(10**5))


N, Q = map(int, input().split())
T = [[0, []] for _ in range(N+1)] #counter, nearest-children
E = [list(map(int, input().split())) for _ in range(N-1)]
PX = [list(map(int, input().split())) for _ in range(Q)]
for e in E:
  T[e[0]][1].append(e[1])
for px in PX:
  T[px[0]][0] += px[1]
for t in T:
  for c in t[1]:
    T[c][0] += t[0]
ans_s = ""
for t in T[1:]:
  ans_s += "%d "%t[0]
print(ans_s)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
T = [[0, [], []] for _ in range(N+1)] #counter, parents, children
E = list(map(int, input().split())) for _ in range(N-1)]
for e in E:
  p, c = e
  T[c][1] += T[p][1]
  T[c][1].append(p)
  for q in T[c][1]:
    T[q][2].append(c)
for _ in range(Q):
  p, x = map(int, input().split())
  T[p][0] += x
  for c in T[p][2]:
    T[c][0] += x
ans_s = ""
for t in T[1:]:
  ans_s += "%d "%t[0]
print(ans_s)