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

Fixed submission:
N, K = map(int, input().split())
 
snukes = [0] * N
for i in range(K):
  d_i = int(input()) # throw away
  a_i = map(int, input().split())
  for a in a_i:
    snukes[a-1] += 1
 
counter = 0
for i in range(N):
  if snukes[i] == 0:
    counter += 1
 
print(counter)

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

snukes = [0] * N
for i in range(K):
  d_i = int(input()) # throw away
  a_i = map(int, input().split())
  for a in a_i:
    snukes[a] += 1

counter = 0
for i in range(N):
  if snukes[i] == 0:
    counter += 1

print(counter)
Problem p02689 (python)

Fixed submission:
## parse input
N, M = map(int, input().split()) # throw N away
Hs = list(map(int, input().split())) # int[N]
Rs = [] # (int, int)[M]

for i in range(M):
  a, b = map(int, input().split())
  Rs.append((a-1, b-1))

## preperation
#height_conds = [False]*N*N # boolean[N, N] if Hs[fst] > Hs[snd]
#for i in range(N):
#  for j in range(i+1, N):
#    height_conds[i*N+j] = Hs[i] > Hs[j]
#    height_conds[j*N+i] = Hs[j] > Hs[i]

## main
goods = [True] * N

for r in Rs:
  a, b = r
  if goods[a]:
  	goods[a] = Hs[a]>Hs[b]#height_conds[a*N+b]
  if goods[b]:
  	goods[b] = Hs[b]>Hs[a]#height_conds[b*N+a]

counter = 0
for i in range(N):
  if goods[i]:
    counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
## parse input
N, M = map(int, input().split()) # throw N away
Hs = list(map(int, input().split())) # int[N]
Rs = [] # (int, int)[M]

for i in range(M):
  a, b = map(int, input().split())
  Rs.append((a-1, b-1))

## preperation
height_conds = [False]*N*N # boolean[N, N] if Hs[fst] > Hs[snd]
for i in range(N):
  for j in range(i+1, N):
    height_conds[i*N+j] = Hs[i] > Hs[j]
    height_conds[j*N+i] = Hs[j] > Hs[i]

## main
goods = [True] * N

for r in Rs:
  a, b = r
  if goods[a]:
  	goods[a] = height_conds[a*N+b]
  if goods[b]:
  	goods[b] = height_conds[b*N+a]

counter = 0
for i in range(N):
  if goods[i]:
    counter += 1

print(counter)
Problem p03221 (python)

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

for i in range(M):
    p, y = map(int, input().split())
    ss[p-1].append((i, y))

ls = [''] * M
for p in range(N):
    s = ss[p]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(p+1).zfill(6)
        ds = str(d+1).zfill(6)
        ls[i] = ps+ds

for l in ls:
    print(l)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ss = {}

for i in range(M):
    p, y = map(int, input().split())
    if not (p-1) in ss:
        ss[p-1] = []
    ss[p-1].append((i, y))

ls = [''] * M
for p in range(N):
    s = ss[p]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(p+1).zfill(6)
        ds = str(d+1).zfill(6)
        ls[i] = ps+ds

for l in ls:
    print(l)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ss = {}

for i in range(M):
    p, y = map(int, input().split())
    if not (p-1) in ss:
        ss[p-1] = []
    ss[p-1].append((i, y))

ls = [''] * M
for p in range(N):
    s = ss[p]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(p+1).zfill(6)
        ds = str(d+1).zfill(6)
        ls[i] = f"{ps}{ds}"

for l in ls:
    print(l)

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

for i in range(M):
    p, y = map(int, input().split())
    ss[p-1].append((i, y))

ls = [''] * M
for j in range(N):
    s = ss[j]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(j+1).zfill(6)
        ys = str(d+1).zfill(6)
        ls[i] = f"{ps}{ys}"

for l in ls:
    print(l)
Problem p02829 (python)

Fixed submission:
a,b=[int(input()) for _ in range(2)]
for i in range(1,4):
    if i!=a and i!=b:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
for i in range(1,4):
    if i!=a and i!=b:
        print(i)
        break
Problem p02836 (python)

Fixed submission:
s=input()
s_len=len(s)
ans=0
for i in range(s_len//2):
    if s[i]!=s[s_len-1-i]:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
s_len=len(s)
ans=0
for i in range(s_len//2):
    if ans[i]!=ans[s_len-1-i]:
        ans+=1
print(ans)
Problem p02847 (python)

Fixed submission:
s=input()
t=["SUN","MON","TUE","WED","THU","FRI","SAT"]
for i in range(7):
    if s==t[i]:
        print(7-i)
        break

Buggy submission (verdict: Runtime Error):
s=input()
t=["SUN","MON","TUE","WED","THU","FRI","SAT"]
for i in range(7):
    if s=t[i]:
        print(7-i)
        break
Problem p02860 (python)

Fixed submission:
n=int(input())
s=input()
ans="No"
if n%2==0 and s[:n//2]==s[n//2:]:
    ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans="No"
if n%2==0 and s[:n//2+1]==s[n//2+1]:
    ans="Yes"
print(ans)
Problem p03013 (python)

Fixed submission:
def main():
    n,m=map(int,input().split())
    res=[1,1]
    flg=0
    mod=10**9+7
    a=n
    gap=[]
    if m!=0:
        a=int(input())
        gap.append(a-1)
        for i in range(m-1):
            b=int(input())
            dif=b-a-1
            if dif==0:
                flg=1
                break
            else:
                gap.append(dif-1)
                a=b
        gap.append(n-a-1)
    else:
        gap.append(n)
    if flg==1:
        print(0)
    else:
        for i in range(2,max(gap)+1):
            res.append((res[i-1]+res[i-2])%mod)
        ans=1
        for i in gap:
            ans=(ans*res[i])%mod
        print(ans)
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,m=map(int,input().split())
    res=[1,1]
    a=int(input())
    gap=[a-1]
    flg=0
    mod=10**9+7
    for i in range(m-1):
        b=int(input())
        dif=b-a-1
        if dif==0:
            flg=1
            break
        else:
            gap.append(dif-1)
            a=b
    if flg==1:
        print(0)
    else:
        gap.append(n-a-1)
        for i in range(2,max(gap)+1):
            res.append((res[i-1]+res[i-2])%mod)
        ans=1
        for i in gap:
            ans=(ans*res[i])%mod
        print(ans)
if __name__=="__main__":
    main()
Problem p03017 (python)

Fixed submission:
n,a,b,c,d=map(int,input().split())
s=input()
ans="Yes"
if c<b:
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d-1):
            if s[i]=="#" and s[i+1]=="#":
                ans="No"
                break
elif c<d:
    for i in range(a-1,d-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
else:
    cnt=0
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-2,d+1):
            if s[i]==".":
                cnt+=1
                if cnt==3:
                    break
            else:
                cnt=0
        if cnt!=3:
            ans="No"
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=input()
ans="Yes"
if c<b:
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d-1):
            if s[i]=="#" and s[i+1]=="#":
                ans="No"
                break
elif c<d:
    for i in range(a-1,d-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
else:
    cnt=0
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d):
            if s[i]==".":
                cnt+=1
                if cnt==3:
                    break
            else:
                cnt=0
        if cnt!=3:
            ans="No"
print(ans)n,a,b,c,d=map(int,input().split())
s=input()
ans="Yes"
if c<b:
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d-1):
            if s[i]=="#" and s[i+1]=="#":
                ans="No"
                break
elif c<d:
    for i in range(a-1,d-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
else:
    cnt=0
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d):
            if s[i]==".":
                cnt+=1
                if cnt==3:
                    break
            else:
                cnt=0
        if cnt!=3:
            ans="No"
print(ans)
Problem p03252 (python)

Fixed submission:
from operator import itemgetter
s=input()
t=input()
u=[]
v=[]
s_len=len(s)
for i in range(s_len):
    s_i=s[i]
    t_i=t[i]
    ts=t_i+s_i
    if s_i!=t_i:
        if ts not in u:
            u.append(ts)
    elif s_i not in v:
        v.append(s_i)
u_len=len(u)
ans="Yes"
if u_len!=0:
    u1=sorted(u)
    u1.append("XX")
    for i in range(u_len):
        if u1[i][0] in v or u1[i][1] in v:
            ans="No"
            break
        elif u1[i][0]==u1[i+1][0] and u1[i][1]!=u1[i+1][1]:
            ans="No"
            break
    if ans=="Yes":
        u2=sorted(u,key=itemgetter(1))
        u2.append("XX")
        for i in range(u_len):
            if u2[i][0]!=u2[i+1][0] and u2[i][1]==u2[i+1][1]:
                ans="No"
                break
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
u=[]
v=[]
s_len=len(s)
for i in range(s_len):
    s_i=s[i]
    t_i=t[i]
    ts=t_i+s_i
    if s_i!=t_i:
        if ts not in u:
            u.append(ts)
    elif s_i not in v:
        v.append(s_i)
u_len=len(u)
ans="Yes"
if u_len!=0:
    u.sort()
    u.append("XX")
    u_len=len(u)
    for i in range(u_len):
        if u[i][0] in v or u[i][1] in v:
            ans="No"
            break
        elif u[i][0]==u[i+1][0] and u[i][1]!=u[i+1][1]:
            ans="No"
            break       
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
u=[]
v=[]
s_len=len(s)
for i in range(s_len):
    s_i=s[i]
    t_i=t[i]
    ts=t_i+s_i
    if s_i!=t_i:
        if ts not in u:
            u.append(ts)
    elif s_i not in v:
        v.append(s_i)
u.sort()
u.append("XX")
ans="Yes"
u_len=len(u)
for i in range(u_len):
    if u[i][0] in v or u[i][1] in v:
        ans="No"
        break
    elif u[i][0]==u[i+1][0] and u[i][1]!=u[i+1][1]:
        ans="No"
        break       
print(ans)
Problem p02753 (python)

Fixed submission:
a = input()
if len(set(a)) > 1:
    print('Yes')
else:
    print('No')

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

if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    blue = (n // (a + b)) * a
    amari = n % (a+b)
    if amari > a:
        blue += a
    else:
        blue += amari

    print(blue)
Problem p02831 (python)

Fixed submission:
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


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

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

print(lcm(a, b))
Problem p02759 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 19:08:31 2020

@author: Kanaru Sato
"""

N = int(input())

ans = N//2 + N%2

print(ans)

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

if N%2 == 0:
  ans = N//2
else:
  ans = N//2 + 1

return(ans)
Problem p02773 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 16:16:18 2020

@author: Kanaru Sato
"""

N = int(input())
D = {}

for i in range(0,N):
    S = input()
    if S not in D:
        D[S] = 1
    if S in D:
        D[S] += 1

Mvalue = max(D.values())

List = []
[List.append(i) for i in D if D[i]==Mvalue]

List.sort()

for i in range(0,len(List)):
    print(List[i])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 02:26:37 2020

@author: Kanaru Sato
"""

def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)
    return result

def differ(S):
    S_dash = list(set(S))
    D = list_difference(S, S_dash)
    if len(D) == 0:
        return S
    if len(D) == 1:
        return D
    if len(D) >= 2:
        return differ(D)

N = int(input())
S = []
[S.append(input()) for i in range(0,N)]

ans = differ(S)
ans.sort()

for i in range(0,len(ans)):
    print(ans[i])
Problem p02881 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn+1):
    if n%i ==0:
        list.append([i,n//i])

dist = list[-1][0]+list[-1][1]-2

print(dist)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn):
    if n%i ==0:
        list.append([i,n//i])

dist = list[-1][0]+list[-1][1]-2

print(dist)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn):
    if n%i ==0:
        list.append([i,n//i])

min = n-1

for i in range(0,len(list)):
    dist = list[i][0]+list[i][1]-2
    if dist <= min:
        min = dist

print(dist)
Problem p02759 (python)

Fixed submission:
import math
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    print(math.ceil(n / 2))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    if m == 0:
        print(10 ** (n - 1))
        return

    numbers = [-1 for _ in range(n)]
    ret = ''
    for _ in range(m):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            ret = -1

        if numbers[s - 1] == -1:
            numbers[s - 1] = c
        elif numbers[s - 1] != c:
            ret = -1

    if ret == -1:
        print(ret)
        return

    for i in range(len(numbers)):
        if numbers[i] == -1:
            if i == 0:
                numbers[i] = 1
            else:
                numbers[i] = 0
        if numbers[i] < 0 or numbers[i] > 9:
            ret = -1
            break
        ret += str(numbers[i])

    print(int(ret))


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

Fixed submission:
[n, m] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
st = [set([]) for _ in range(n)]
for i in range(m):
    [a, b] = [int(i) for i in input().split()]
    st[a-1].add(b-1)
    st[b-1].add(a-1)
cnt = 0
for i, height in enumerate(h):
    line = []
    for huga in st[i]:
        line.append(h[huga])
    if len(line) == 0 or height > max(line):
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
[n, m] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
st = [{} for _ in range(n)]
for i in range(m):
    [a, b] = [int(i) for i in input().split()]
    st[a-1].add(b-1)
    st[b-1].add(a-1)
cnt = 0
for i, height in enumerate(h):
    line = []
    for huga in st[i]:
        line.append(h[huga])
    if height > max(line):
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
[n, m] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
st = [[] for _ in range(n)]
for i in range(m):
    [a, b] = [int(i) for i in input().split()]
    st[a-1].append(b-1)
    st[b-1].append(a-1)
cnt = 0
for i, height in enumerate(h):
    line = []
    hoge = set(st[i])
    for huga in hoge:
        line.append(h[huga])
    if type(huga) is int:
        if height > huga:
            cnt += 1
    elif height > max(huga):
        cnt += 1
print(cnt)
Problem p02819 (python)

Fixed submission:
def main():
  x = int(input())
  sosu = []
  tgt = 2
  is_sosu = True
  while(1):
    for i in sosu:
      if tgt % i == 0:
        is_sosu = False
        break
    if is_sosu:
      sosu.append(tgt)
    if tgt >= x and is_sosu:
      print(tgt)
      break
    else:
      tgt += 1
      is_sosu = True

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
def main():
  x = int(input())
  sosu = [2]
  tgt = 2
  is_sosu = True
  while(1):
    for i in sosu:
      if tgt % i = 0:
        flag = False
        break
    if tgt < x:
      sosu.append(tgt)
      tgt += 1
    else:
      print(tgt)
      break

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

Fixed submission:
import math
N = int(input())
print(math.ceil(N/2))

Buggy submission (verdict: Runtime Error):
import math
N = input()
print(math.ceil(N/2))
Problem p02793 (python)

Fixed submission:
from fractions import gcd


def main():
        
    N = int(input())
    A = list(map(int, input().split())) 
    MOD = 10**9 + 7


    l = 1

    for a in A:
        l = l * a // gcd(l, a)


    ans = 0
    for a in A:
        ans += (l // a)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import gcd

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm, a)


ans = 0
for a in A:
    # フェルマーの小定理
    ans += lcm * pow(a, MOD-2, MOD)
    ans %= MOD


print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

lcm = 1
for a in A:
    lcm = lcm * a // gcd(lcm, a)


ans = 0
for a in A:
    # フェルマーの小定理
    ans += lcm * pow(a, MOD-2, MOD)
    ans %= MOD


print(ans)
Problem p02990 (python)

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

def nCr(n,r):
  if n < 0 or r < 0 or n < r: return 0
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n
  
  # 分子のn*(n-1)*...がr個分続くやつ
  numerator = [n-r+k+1 for k in range(r)]
  # 分母：r!=r*(r-1)*...*3*2の要素
  denominator = [k+1 for k in range(r)]
  
  # 分母の要素で割れる部分を割っていく部分
  for p in range(2, r+1):
    # 分母は1,2,3,...rのようになっており、1は意味がないのでスキップした形か
    pivot = denominator[p-1]
    if pivot > 1:
      # 分子のX番目と分母のX-offset番目が共通の約数を持つということだと思う。piv分ずれているのだから、pivの倍数というところか
      offset = (n-r) % p
      for k in range(p-1, r, p):
        # 約分できる要素について割る
        numerator[k - offset]  /= pivot
        denominator[k] /= pivot
        
  ret = 1
  for k in range(r):
    if numerator[k] > 1: ret *= int(numerator[k])
      
  return ret

def nPr(n,r):
    tmp = 1
    for i in range(n,n-r,-1):
        tmp *= i
    return tmp

for i in range(1, K+1):
    sukima = nCr(N-K+1, i)
    p = nPr(K-1, i-1) // nPr(i-1, i-1)
    print(sukima*p%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def nCr(n,r):
    if n == r:
        return 1
    r = min(n-r,r)
    if r == 0: return 1
    # reduceは第一引数で与えた関数を第二引数のiterbleのそれぞれで実行した結果をもどす
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under



MOD = 10**9+7
N,K = map(int, input().split())

for i in range(1, K+1):
    blue = nCr(K-1, i-1)
    red = nCr(N-K+1, i)
    print(blue*red%MOD)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    # reduceは第一引数で与えた関数を第二引数のiterbleのそれぞれで実行した結果をもどす
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under



MOD = 10**9+7
N,K = map(int, input().split())

for i in range(1, K+1):
    blue = nCr(K-1, i-1)
    red = nCr(N-K+1, i)
    print(blue*red%MOD)
Problem p03017 (python)

Fixed submission:
n,a,b,c,d = map(int, input().split())
a -= 1
b -= 1
s = input()
ans = "No"
snk = s[a:c].count("##")
fnk = s[b:d].count("##")
if snk == 0 and fnk == 0:
  if c > d:
    if s[b-1:d+1].count("...") >= 1:
      ans = "Yes"
  else:
    ans = "Yes"
    
print(ans)

Buggy submission (verdict: Runtime Error):

n,a,b,c,d = map(int, input().split())

s = input()

#すぬけ君のゴールがふぬけ君より右にある場合
if c > d:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:c].count("##") == 0 and s[b:d].count("##") == 0:
    if s[b-1:d+1].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  s[a:c].count("##") == 0 and s[b:d].count("##") == 0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = map(int, input().split())
​
s = input()
​
​
#すぬけ君のゴールがふぬけ君より右にある場合
if c > d:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:].count("##") == 0:
    if s[b-1:d+1].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    print("Yes")
  else:
    print("No")
Problem p03053 (python)

Fixed submission:
from collections import deque

def main():
    H,W = map(int, input().split())

    A = [[a for a in input()] for _ in range(H)]
    #stack = deque([(i, j) for i in range(H) for j in range(W) if A[i][j]=="#"])
    stack = [(i, j) for i in range(H) for j in range(W) if A[i][j]=="#"]
    ans = 0
    flag = False
    if stack:
        flag = True
    while flag:
        ans += 1
        flag = False
        #new_stack = deque()
        new_stack = []
        for a,b in stack:
        #while stack:
            #a,b = stack.pop() # 取り出す
            # A[a][b]の隣接マスについて調べる
             # 上
            if a != 0 and A[a-1][b] == ".": # 白の場合
                    A[a-1][b] = "#"
                    new_stack.append((a-1,b))
             # 下
            if a != H-1 and A[a+1][b] == ".": # 白の場合
                    A[a+1][b] = "#"
                    new_stack.append((a+1,b))
            # 左
            if b != 0 and A[a][b-1] == ".": # 白の場合
                    A[a][b-1] = "#"
                    new_stack.append((a,b-1))
            # 右
            if b != W-1 and A[a][b+1] == ".": # 白の場合
                    A[a][b+1] = "#"
                    new_stack.append((a,b+1))
        stack = new_stack
        if stack:
            flag = True
        else:
            ans -= 1 

    print(ans)
            


if __name__ == "__main__":
    main()

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

def main():
    H,W = map(int, input().split())

    A = [[a for a in input()] for _ in range(H)]
    stack = deque([(i, j) for i in range(H) for j in range(W) if A[i][j]=="#"])
    
    ans = 0
    flag = False
    if stack:
        flag = True
    while flag:
        ans += 1
        flag = False
        new_stack = deque()
        for a,b in stack:
        #while stack:
            a,b = stack.pop() # 取り出す
            # A[a][b]の隣接マスについて調べる
             # 上
            if a != 0 and A[a-1][b] == ".": # 白の場合
                    A[a-1][b] = "#"
                    new_stack.append((a-1,b))
             # 下
            if a != H-1 and A[a+1][b] == ".": # 白の場合
                    A[a+1][b] = "#"
                    new_stack.append((a+1,b))
            # 左
            if b != 0 and A[a][b-1] == ".": # 白の場合
                    A[a][b-1] = "#"
                    new_stack.append((a,b-1))
            # 右
            if b != W-1 and A[a][b+1] == ".": # 白の場合
                    A[a][b+1] = "#"
                    new_stack.append((a,b+1))
        stack = new_stack
        if stack:
            flag = True
        else:
            ans -= 1 

    print(ans)
            


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

Fixed submission:
s = input()

ans = ""
for i in range(len(s)):
  if s[i] == "1":
    ans  += "9"
  else:
    ans += "1"
    
print(ans)

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


for i in range(len(s)):
  if s[i] == "1":
    s[i] = "9"
  else:
    s[i] = "1"
    
print(s)