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

Fixed submission:
x = int(input())

if x >= 30:
    print('Yes')
else:
    print('No')

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

def f(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
u = f(k)

def yakusu(n):
    u = [n]
    i = 2
    while i <= n/2:
        if n%i == 0:
            u.append(i)
        i += 1
    return sorted(list(u))

v = yakusu(k-1)
del v[-1]

if k==1:
    print(1)
elif k%2==0 or len(u)>1:
    print(-1)
else:
    for i in v:
        if int('7'*i)%k==0:
            print(i)
            break
    else:
        print(k-1)
Problem p02682 (python)

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

if k<=a:
    print(k)
elif a<k<=a+b:
    print(a)
else:
    print(a-(k-(a+b)))

Buggy submission (verdict: Runtime Error):
2 1 1 3
Problem p02915 (python)

Fixed submission:
n=int(input())
print(n*n*n)

Buggy submission (verdict: Runtime Error):
 print(n**3)
Problem p02572 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
pans = 0
sum_ = sum(a)%(10**9+7)
for i in range(n-1):
    sum_ -= a[i]
    ans = sum_ * a[i]
    ans = ans % (10**9+7)
    pans += ans
print(pans%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
pans = 0
sum_ = sum(a)%(10**9+7)
for i in range(n-1):
    sum -= a[i]
    ans = sum * a[i]
    ans = ans % (10**9+7)
    pans += ans
print(pans%(10**9+7))
Problem p02987 (python)

Fixed submission:
s = input()
first = s[0]
count = 0
s_count = 0
num = 0
second = ""
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second = s[i]  
        num = i
for i in range(1,len(s)):
    if num == i:
        m = 0
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
first = s[0]
count = 0
s_count = 0
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second =s[i]  
        num = i
for i in range(1,len(s)):
    if num == i:
        m = 0
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
first = s[0]
count = 0
s_count = 0
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second =s[i]  
        num = i
for i in range(len(s)):
    if num == i:
        continue
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
mat = [0 for i in range(n+1)]

for i in range(m):
    mat[int(input())] = -1

for i in range(n):
    if i == 0:
        mat[i] = 1
    if mat[i] == -1:
        continue
    if i + 1 < n+1:
        if mat[i+1] != -1:
            mat[i+1] += mat[i]
    if i + 2 < n+1:
        if mat[i+2] != -1:
            mat[i+2] += mat[i]
if mat[-1] >= 0:
    print(mat[-1]%1000000007)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
mat = [0 for i in range(n+1)]

for i in range(m):
    mat[int(input())] = -1

for i in range(n):
    if i == 0:
        mat[i] = 1
    if mat[i] == -1:
        continue
    if i + 1 < n+1:
        if mat[i+1] != -1:
            mat[i+1] += mat[i]
    if i + 2 < n+1:
        if mat[i+2] != -1:
            mat[i+2] += mat[i]
if mat[-1] => 0:
    print(mat[-1]%1000000007)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
mat = [0 for i in range(n+1)]

for i in range(m):
    mat[int(input())] = -1

for i in range(n):
    if i == 0:
        mat[i] = 1
    if mat[i] == -1:
        continue
    if i + 1 < n+1:
        if mat[i+1] != -1:
            mat[i+1] += mat[i]
    if i + 2 < n+1:
        if mat[i+2] != -1:
            mat[i+2] += mat[i]
    print(mat)
if mat[-1] => 0:
    print(mat[-1]%1000000007)
else:
    print(0)
Problem p03041 (python)

Fixed submission:
n,k = map(int,input().split())
s = input()
komoji = str.lower(s[k-1])
if k-1 != 0 and k-1 != n-1:
    sum = s[0:k-1] +komoji+s[k:]
elif k-1 == 0:
    sum = komoji + s[k:]
else:
    sum = s[0:k-1] + komoji
print(sum)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
print(str.lower(s[k]))
Problem p03127 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
gcd = a[-1]
def Euclid(n1,n2):
    if n1 % n2 == 0:
        return n2
    return Euclid(n2,n1%n2)
for i in range(n-1):
    gcd = Euclid(gcd,a[(-1)*(i+2)])
print(gcd)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
a.sort()
gcd = a[-1]
for i in range(n-1):
    gcd = math.gcd(gcd,a[(-1)*(i+2)])
print(gcd)
Problem p03221 (python)

Fixed submission:
n,m = map(int,input().split())
s = []
for i in range(m):
    a =list(map(int,input().split()))
    a.append(i)
    s.append(a)
s.sort()
ans = [0 for i in range(m)]
num = 0
ans_ = ""
for i in range(m):
    if num != s[i][0]:
        num = s[i][0]
        count = 1
    ans_ = str(s[i][0])
    ans__ = str(count)
    for j in range(5):
        if len(ans_) < 6:
            ans_ = "0"+ans_
        if len(ans__) < 6:
            ans__ = "0" + ans__
    ans[s[i][2]] = ans_+ans__
    count += 1
for i in range(m):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    P,Y = map(int,input().split())
    a.append(P)
    b.append(Y)
#ここまで情報のインプット

#基本方針はまだ扱っていない最小のお金を持つ栄養ドリンクをとっていく。
#つまりは値がちいさいものから順に在庫が切れるまで選択するということ。

count = 0
ans = 0
i = 0
A = sorted(a)
while True:
    if m-b[a.index(A[i])] > 0:
        m -= b[a.index(A[i])]
        ans += A[i] * b[a.index(A[i])]
    else:
        ans += A[i]* m
        break
    i+=1
print(ans)
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

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

A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
ai = 0
bi = 0
t = 0
while t < k and (ai < len(A) or bi < len(B)):
  if ai < len(A) and bi < len(B):
    a = A[ai]
    b = B[bi]
    if a < b:
      ai += 1
      t += a
      if t =< k:
        ans += 1
    else:
      bi += 1
      t += b
      if t =< k:
        ans += 1
  elif ai < len(A):
    ai += 1
    t += A[ai]
    if t =< k:
      ans += 1
  else:
    bi += 1
    t += B[bi]
    if t =< k:
      ans += 1
print(ans)
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if s <= w:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
s = input()
if len(s) < 4:
  print('0')
else:
  cnt = 0
  for i in range(len(s)-3):
    if int(s[i:i+2]) %2 != 0:
      continue
    if i+4 > len(s):
      break
    for j in range(i+4, len(s)):
      if int(s[i:j+1]) % 2019 == 0:
        cnt += 1
  print(cnt)
Problem p02759 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
  print(N//2)
else:
  print(N//2+1)

Buggy submission (verdict: Runtime Error):
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*n
    self.rank = [0]*n
    
  def find_root(self, e):
    if self.root[e] < 0:
      return e
    else:
      r = self.find_root(self.root[e])
      self.root[e] = r
      return r
    
  def combine(self, e1, e2):
    root1 = self.find_root(e1)
    root2 = self.find_root(e2)
    if root1 == root2:
      pass
    elif self.rank[root1] < self.rank[root2]:
      self.root[root1] += self.root[root2]
      self.root[root2] = root1
      self.rank[root1] = self.rank[root2] + 1
    elif self.rank[root2] < self.rank[root1]:
      self.root[root2] += self.root[root1]
      self.root[root1] = root2
      self.rank[root2] = self.rank[root1] + 1
    else:
      self.root[root2] += self.root[root1]
      self.root[root1] = root2
      self.rank[root2] += 1
      
  def in_the_same_group(self, e1, e2):
      r1 = self.find_root(e1)
      r2 = self.find_root(e2)
      if r1 == r2:
        return True
      return False
  

NMK = input().split()
N = int(NMK[0])
M = int(NMK[1])
K = int(NMK[2])
uf = UnionFind(N)
from collections import defaultdict
friend_list = [0]*N
for _ in range(M):
  AB = input().split()
  A = int(AB[0])-1
  B = int(AB[1])-1
  uf.combine(A,B)
  friend_list[A] += 1
  friend_list[B] += 1

block_list = [0]*N
for _ in range(K):
  CD = input().split()
  C = int(CD[0])-1
  D = int(CD[1])-1
  if uf.in_the_same_group(C, D):
    block_list[C] += 1
    block_list[D] += 1

cnt = defaultdict(int)
ans = []
for i in range(N):
  cnt[i] = -uf.root[uf.find_root(i)] - 1 - friend_list[i] - block_list[i]
  ans.append(str(cnt[i]))

print(" ".join(ans))
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
if n % 2 == 0:
  end = n//2
  start = end
  if s[:end] == s[start:]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n % 2 == 0:
  end = n//
  start = end
else:
  end = n//2+1
  start = n//2
if s[:end] == s[start:]:
  print('Yes')
else:
  print('No')
Problem p02862 (python)

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

from operator import mul
from functools import reduce
def combination_count(n, r):
  r = min(n-r, r)
  num = reduce(modmul, range(n, n-r, -1), 1)
  denom = reduce(modmul, range(r, 1, -1), 1)
  return num*mod_inv(denom,10**9+7)

def modmul(a, b):
  return mul(a,b)%(10**9+7)

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

if (x+y)%3 != 0:
  print('0')
else:
  m = (2*x - y)//3
  n = x - 2*m
  if m < 0 or n < 0:
    print('0')
  else:
    c = combination_count(m+n, m)
    print(c%(10**9+7))

Buggy submission (verdict: Runtime Error):

from operator import mul
from functools import reduce
def combination_count(n, r):
  r = min(n-r, r)
  num = reduce(modmul, range(n, n-r, -1), 1)
  denom = reduce(modmul, range(r, 1, -1), 1)
  return num*pow(denom, 10**9+5, 10**9+7)

def modmul(a, b):
  return mul(a,b)%(10**9+7)

def modinv(a, b):
  d, x, y = extgcd(a, b)
  return (d + x%b) % b

def gcd(a, b):
  if (b==0):
    return a
  else:
    return gcd(b, a%b)

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]


if (x+y)%3 != 0:
  print('0')
else:
  m = (2*x - y)//3
  n = x - 2*m
  c = combination_count(m+n, m)
  print(c%(10**9+7))
Problem p03041 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns()) #int
na = lambda: list(map(int, stdin.readline().split())) #int,list
ns = lambda: stdin.readline().rstrip()  # str

n,k = na()
s=ns()
print(s[:k-1]+s[k-1].lower()+s[k:])

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns()) #int
na = lambda: list(map(int, stdin.readline().split())) #int,list
ns = lambda: stdin.readline().rstrip()  # str

n,k = na()
s=ns()
print(s.replace(s[k+1],s[k+1].lower()))
Problem p03104 (python)

Fixed submission:
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
a,b = rl()
c=a%4
d=b%4
ans=0
for i in range(4-c):
    ans^=a+i
for i in range(d+1):
    ans^=b-i
print(ans)

Buggy submission (verdict: Runtime Error):
zimport sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
a,b = rl()
c=a%4
d=b%4
ans=0
for i in range(4-c):
    ans^=a+i
for i in range(d+1):
    ans^=b-i
print(ans)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
a, b, c = map(int, (input().split()))
print(max(c - (a - b), 0))
Problem p02912 (python)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
h = []

for a in A: heapq.heappush(h, -a)
for _ in range(M):
	a = heapq.heappop(h) * -1
	a //= 2
	heapq.heappush(h, -a)

sum = 0
for _ in range(N): 
	sum -= heapq.heappop(h)
print(sum)

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

for _ in range(M):
	a = A.pop()
	a //= 2
	for i in A:
		if i > a:
			A.insert(A.index(i), a)
			break

sum = 0
for a in A: sum += a
print(sum)
Problem p02570 (python)

Fixed submission:
list1 = input().split(" ")
if int(list1[0]) <= int(list1[1]) * int(list1[2]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
list1 = input().split(" ")
if int(list1[0]) <= int(list1[1]) * int(list[2]):
    print("Yes")
else:
    print("No")
Problem p02659 (python)

Fixed submission:
A, B = input().split()

print(int(A) * round(float(B) * 100) // 100)

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

print(A * B // 1)
Problem p02594 (python)

Fixed submission:
print("Yes" if int(input())>=30 else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if int(input())>="30" else "No")
Problem p02659 (python)

Fixed submission:
a, b = input().split()
print(int(a)*int(b[0] + b[2:]) // 100)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(int(a*b))
Problem p02779 (python)

Fixed submission:
def solve(n, a):
    return "YES" if len(set(a)) == n else "NO"

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Buggy submission (verdict: Runtime Error):
def solve(n, a):
    for i in range(n-1):
        if a[i] == a[i+1]:
            return "NO"
    return "YES"

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))
Problem p03108 (python)

Fixed submission:
import numpy as np

def solve(n, m, a, b):
    p = [-1] * (n+1)
    u = [1] * (n+1)
    def find(x):
        if p[x] == -1:
            return x
        else:
            return find(p[x])
    total = n * (n-1) // 2
    res = [total]
    for i in range(m-1, 0, -1):
        x, y = a[i], b[i]
        px = find(x)
        py = find(y)
        if px > py:
            px, py = py, px
        if px != py:
            n1 = u[px]
            n2 = u[py]
            p[py] = px
            u[px] = n1 + n2
            total -= n1 * n2
        res.append(total)
    return res[::-1]

n, m = map(int, input().split())
a = np.zeros(m, dtype=int)
b = np.zeros(m, dtype=int)
for i in range(m):
    a[i], b[i] = map(int, input().split())
print("\n".join(map(str, solve(n, m, a, b))))

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

def solve(n, m, a, b):
    p = [-1] * (n+1)
    u = [1] * (n+1)
    def find(x):
        if p[x] == -1:
            return x
        else:
            return find(p[x])
    def size(x):
        px = find(x)
        return u[px]
    total = n * (n-1) // 2
    res = [total]
    for x, y in zip(a[::-1], b[::-1]):
        px = find(x)
        py = find(y)
        if px != py:
            n1 = size(x)
            n2 = size(y)
            p[py] = px
            u[px] = n1 + n2
            total -= n1 * n2
        res.append(total)
    return res[::-1][1:]

n, m = map(int, input().split())
a = np.zeros(m, dtype=int)
b = np.zeros(m, dtype=int)
for i in range(m):
    a[i], b[i] = map(int, input().split())
print("\n".join(map(str, solve(n, m, a, b))))
Problem p02659 (python)

Fixed submission:
from decimal import *

A, B = input().split()
print(int(Decimal(A)*Decimal(B)))

Buggy submission (verdict: Runtime Error):
A, B =int(input()), float(input())
print(int(A*B))
Problem p02891 (python)

Fixed submission:
S = list(input())
K = int(input())

S1 = list(S)
cnt1 = 0
for i in range(1, len(S1)):
    if S1[i] == S1[i - 1]:
        S1[i] = '*'
        cnt1 += 1

S2 = list(S) * 2
cnt2 = 0
for i in range(1, len(S2)):
    if S2[i] == S2[i - 1]:
        S2[i] = '*'
        cnt2 += 1
        
S3 = list(S) * 3
cnt3 = 0
for i in range(1, len(S3)):
    if S3[i] == S3[i - 1]:
        S3[i] = '*'
        cnt3 += 1

# print("#", S1, S2, S3)
# print("#", cnt1, cnt2, cnt3)
ans = cnt1 + (cnt2 - cnt1) * (K // 2) + (cnt3 - cnt2) * ((K - 1) // 2)
print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
ans = 0

if len(S) == 1:
    ans = K//2
elif len(set(s)) == 1:
    ans = int(len(S)*K/2)
else:
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            ans += 1
            S[i+1] = "#"

    ans *= K

    if S[0] == S[-1]:
        ans += K-1
    # print(S)
print(ans)
Problem p03017 (python)

Fixed submission:
n, a, b, c, d = list(map(int, input().split()))
s = input()

jump = 0
if c < d:
    for i in range(a, d-1):
        if s[i-1] == s[i] == "#":
            print("No")
            break
    else:
        print("Yes")            
else:
    for i in range(a, c-1):
        if s[i-1] == s[i] == "#":
            print("No")
            break
    else:
        for i in range(b-1, d):
            if s[i-1] == s[i+1] == s[i] ==".":
                print("Yes")
                break
        else:
            print("No")

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

flag = 0
if s[c-1] == "#" or s[d-1] == "#":
    flag = 1
elif s[a-1] == "#" or s[b-1] == "#":
    flag = 1
elif c == d:
    flag == 1
else:
    for i in range(n-1):
        if s[i] == s[i+1] == "#":
            flag = 1
            break

if flag == 1:
    print("No")
elif c > d:
    ans = 0
    if s[c-2] == "#" or s[c] == "#":
        print("No")
    else:
        for i in range(a-1,n-2):
            if s[i] == s[i+1] == s[i+2] ==".":
                ans = 1
                break
        if ans == 1:
            print("Yes")
        else:
            print("No")
else:
    print("Yes")

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

flag = 0
if s[c-1] == "#" or s[d-1] == "#":
    flag = 1
elif s[a-1] == "#" or s[b-1] == "#":
    flag = 1
else:
    for i in range(n-1):
        if s[i] == s[i+1] == "#":
            flag = 1
            break

if flag == 1:
    print("No")
elif c > d:
    ans = 0
    if s[c-2] == "#" or s[c] == "#":
        print("No")
    else:
        for i in range(a-1,n-2):
            if s[i] == s[i+1] == s[i+2] ==".":
                ans = 1
                break
        if ans == 1:
            print("Yes")
        else:
            print("No")
else:
    print("Yes")

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

flag = 0
if s[c-1] == "#" or s[d-1] == "#":
    flag = 1
elif s[a-1] == "#" or s[b-1] == "#":
    flag = 1
else:
    for i in range(n-1):
        if s[i] == s[i+1] == "#":
            flag = 1
            break

if flag == 1:
    print("No")
elif c > d:
    ans = 0
    if s[c-2] == "#" or s[c] == "#":
        print("No")
    else:
        for i in range(a-1,n-2):
            if s[i] == s[i+1] == s[i+2] ==".":
                ans = 1
                break
        if ans == 1:
            print("Yes")
        else:
            print("No")
else:
    print("Yes")
Problem p03053 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())

grid = [[-1]*W for _ in range(H)]

queue = deque([])

ans = 0

# while True:
#     f = 0
for i in range(H):
    s = input()
    for j, ss in enumerate(s):
        if ss =="#":
            queue.append((i, j))
            grid[i][j] = 0

#黒点をスタート地点とし、上下左右に移動した時の移動距離を記録していく
while queue:
    h, w = queue.popleft()
    for i in [h-1, h+1]:
            if i >= 0 and i < H:
                if grid[i][w] == -1:
                    grid[i][w] = grid[h][w]+1
                    queue.append((i, w))
    for j in [w-1, w+1]:
        if j >= 0 and j < W:
            if grid[h][j] == -1:
                grid[h][j] = grid[h][w]+1
                queue.append((h, j))

# print(grid)
print(max([max(b) for b in grid]))

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

H, W = map(int, input().split())

grid = [[-1]*W for _ in range(H)]]

queue = deque([])

ans = 0

# while True:
#     f = 0
for i in range(H):
    s = input()
    for j, ss in enumerate(s):
        if ss = ="#":
            queue.append((i, j))
            grid[i][j] = 0

#黒点をスタート地点とし、上下左右に移動した時の移動距離を記録していく
while queue:
    h, w = queue.popleft()
    for i in [h-1, h+1]:
            if i >= 0 and i < H:
                if grid[i][w] == -1:
                    grid[i][w] = grid[h][w]+1
    for j in [w-1, w+1]:
        if j >= 0 and j < W:
            if grid[h][j] == -1:
                grid[h][j] = grid[h][w]+1

print(max(max[(b) for b in grid]))
Problem p03072 (python)

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

cnt = 0
for i in range(len(H)):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)

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

ans = 0

for i in range(n):
    if max(h[0:i]) >= h[i] and h[0] >= h[i]:
        ans += 1

print(ans)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

def dfs(st, depth=0):
    dist[st] = depth
    for to, c in tree[st]:
        if dist[to]>=0:
            continue
        dfs(to, depth+c)


N = int(input())
tree = [[] for _ in range(N)]
dist = [-1]*N

for _ in range(N-1):
    a,b,c = map(int, input().split())
    tree[a-1].append((b-1, c))
    tree[b-1].append((a-1, c))

Q, K = map(int, input().split())
dfs(K-1, 0)
# print(dist)
# print(tree)
for _ in range(Q):
    x, y = map(int, input().split())
    print(dist[x-1]+dist[y-1])

Buggy submission (verdict: Runtime Error):
def dfs(st, depth=0):
    dist[st] = depth
    for to, c in tree[st]:
        if dist[to]>=0:
            continue
        dfs(to, depth+c)


N = int(input())
tree = [[] for _ in range(N)]
dist = [-1]*N

for _ in range(N-1):
    a,b,c = map(int, input().split())
    tree[a-1].append((b-1, c))
    tree[b-1].append((a-1, c))

Q, K = map(int, input().split())
dfs(K-1, 0)
# print(dist)
# print(tree)
for _ in range(Q):
    x, y = map(int, input().split())
    print(dist[x-1]+dist[y-1])