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

Fixed submission:
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(p)):
    try:
        pf = p[i]
        ps = p[i+1]
        pt = p[i+2]
        il = [int(pf),int(ps),int(pt)]
        max_p = max(il)
        il.remove(max_p)
        if int(ps) == max(il):
            a += 1
    except:
        pass
print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(n)):
    pf = p[i]
    ps = p[i+1]
    pt = p[i+2]
    il = [int(pf),int(ps),int(pt)]
    max_p = max(il)
    il.remove(max_p)
    if int(ps) == max(il):
        a += 1
print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(n)):
    pf = p[i]
    ps = p[i+1]
    pt = p[i+2]
    il = [int(pf),int(ps),int(pt)]
    max_p = max(il)
    il.remove(max_p)
    if int(ps) = max(il):
        a += 1
print(a)
Problem p03078 (python)

Fixed submission:
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

X,Y,Z,K = nums()
A = nums()
B = nums()
C = nums()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = [bi + ai for bi in B for ai in A]
AB.sort(reverse=1)
res = []
for ab_sum in AB[:K]:
    for ci in C[:K]:
        res.append(ab_sum + ci)
res.sort(reverse=True)
for ans in res[:K]:
    print(ans)

Buggy submission (verdict: Runtime Error):
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

X,Y,Z,K = nums()
A = nums()
B = nums()
C = nums()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = [bi + ai for bi in B for ai in A]
res = []
for ab_sum in AB[:K]:
    for ci in C[:K]:
        res.append(ab_sum + ci)
res.sort(reverse=True)
for ans in res[:K]:
    print(ans)
Problem p02747 (python)

Fixed submission:

S = input()
st = []
if len(S) %2 != 0 :
    print('No')
else :
    for i in range(len(S) // 2) :
        st.append(S[i*2:i*2+2])
      
    st = list(set(st)) 
    if len(st) == 1 and st[0] == 'hi' :
        print('Yes')
    else :
        print('No')

Buggy submission (verdict: Runtime Error):
S = input()
st = []
if len(S) %2 != 0 :
    print('No')
else :
    for i in range(len(S) // 2) :
        st.append(S[i:i+2])
      
    st = list(set(st))) 
    if len(st) == 1 and st[0] == 'hi' :
        print('Yes')
    else :
        print('No')
Problem p03139 (python)

Fixed submission:
import numpy as np
x = np.array(input().split(' '), int)
print(x[1:].min(),' ', 0 if x[0] >= x[1:].sum() else x[1:].sum() - x[0])

Buggy submission (verdict: Runtime Error):
x = np.array(input().split(' '), int)
print(x[1:].min(),' ', 0 if x[0] >= x[1:].sum() else x[1:].sum() - x[0])
Problem p03577 (python)

Fixed submission:
x=input()
print(x[0:len(x)-8])

Buggy submission (verdict: Runtime Error):
print input.rstrip('FESTIVAL')
Problem p02898 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
ok_list = list()
for data in h:
    if data >= k:
        ok_list.append(data)
print(len(ok_list))

Buggy submission (verdict: Runtime Error):
count = 0
N = int(input())
K = int(input())
hi_list = list()
while count < N:
    count += 1
    hi = int(input())
    hi_list.append(hi)
ok_list = list()
for data in hi_list:
    if data >= K:
        ok_list.append(data)
print(len(ok_list))
Problem p02697 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1
    count = 0
    if N%2 == 0:
        p = set()
        while count < M:
            if right-left == N//2 or N-(right-left) in p:
                left += 1
                continue
            print(left,right)
            p.add(right-left)
            left += 1
            right -= 1
            count += 1
    else:
        while count < M:
            print(left,right)
            left += 1
            right -= 1
            count += 1
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1
    count = 0
    if N%2 == 0:
        raise Exception
        while count < M:
            if right-left == N//2:
                left += 1
                right -= 1
                continue
            print(left,right)
            left += 1
            right -= 1
            count += 1
    else:
        while count < M:
            print(left,right)
            left += 1
            right -= 1
            count += 1
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

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

Fixed submission:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
import math
from itertools import accumulate

def mod_factorial(n):
    value = 1
    for i in range(n,0,-1):
        value*=i
        value%=MOD

    return value

def solve(N: int, x: "List[int]"):
    dif_x = []

    # factmod[i] = (N-1)!/iをMODで割ったあまり
    factmod = [0]*(N)
    factmod[1] = mod_factorial(N-1)
    for i in range(1,N):
        dif_x.append(x[i]-x[i-1])
    
    for i in range(2,N):
        factmod[i] = factmod[1]*pow(i,MOD-2,MOD)
    
    accum_fact_mod = list(accumulate(factmod))
        
    answer = 0

    for i in range(N-1):
        answer += accum_fact_mod[i+1]*dif_x[i]
        answer %= MOD
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
import math
from itertools import accumulate

def solve(N: int, x: "List[int]"):
    gyakusu = []
    dif_x = []
    for i in range(1,N):
        gyakusu.append(1/i)
        dif_x.append(x[i]-x[i-1])
    
    accum_gyakusu = list(accumulate(gyakusu))
    answer = 0

    for i in range(N-1):
        answer += accum_gyakusu[i]*dif_x[i]
        answer %= MOD
    
    print(int(answer*math.factorial(N-1)%MOD))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
import math
from itertools import accumulate

# def mod_factorial(n):
#     value = 1
#     for i in range(n,0,-1):
#         value*=i
#         value%=MOD

#     return value

def solve(N: int, x: "List[int]"):
    gyakusu = []
    dif_x = []
    for i in range(1,N):
        gyakusu.append(1/i)
        dif_x.append(x[i]-x[i-1])
    
    accum_gyakusu = list(accumulate(gyakusu))
    answer = 0
    for i in range(N-1):
        answer += accum_gyakusu[i]*dif_x[i]
        answer %= MOD
    # print(answer)
    
    print(int(answer*math.factorial(N-1)%MOD))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x)

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

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(X: int):
    dp = [[-1]*(X+1) for _ in range(7)]
    price = [100,101,102,103,104,105]
    m = [10**5]*6

    for i in range(7):
        dp[i][0] = 10**5

    ## i番目まででjを払えるか
    for i in range(6):
        for j in range(X+1):
            if dp[i][j]>=0:
                dp[i+1][j] = m[i]
            elif j < price[i] or dp[i+1][j-price[i]]<=0:
                dp[i+1][j] = -1
            else:
                dp[i+1][j] = dp[i+1][j-price[i]]-1

    if dp[6][X]>=0:
        print(1)
    else:
        print(0)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(X: int):
    dp = [[False]*(X+1) for _ in range(7)]
    price = [100,101,102,103,104,105]
    X = 10000

    for i in range(7):
        dp[i][0] = True

    ## i番目まででjを払えるか
    for i in range(6):
        for j in range(X+1):
            if j >= price[i]:
                for k in range(1,j//price[i]+1):
                    if j-k*price[i]>=0:
                        dp[i+1][j] |= dp[i][j] or dp[i][j-k*price[i]]
                    if dp[i+1][j]:
                        break
            else:
                dp[i+1][j] = dp[i][j]

    if dp[6][X]:
        print(1)
    else:
        print(0)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

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

Fixed submission:
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, x: "List[int]", y: "List[int]"):
    pattern = list(itertools.permutations(range(N)))
    sum_dist = 0
    for p in pattern:
        for i in range(1,N):
            sum_dist+=((x[p[i]]-x[p[i-1]])**2+(y[p[i]]-y[p[i-1]])**2)**(1/2)

    print(sum_dist/len(pattern))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from itertools import permutations

def main():
    N = int(input())
    xy = [tuple(map(int,input().split())) for _ in range(N)]
    answer = 0
    for perm in permutations(list(range(N))):
        all_distance = 0

        for i in range(N-1):
            all_distance += ((perm[i+1][1]-perm[i][1])**2 + (perm[i+1][0]-perm[i][0])**2)**(1/2)

        answer = min(answer,all_distance)
    print(answer)
    return


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

Fixed submission:
n, k = map(int, input().split())
h = [int(x) for x in input().split() if int(x)>=k]
print(len(h))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(x) for x in input().split() if x>=k]
print(sum(h))
Problem p02922 (python)

Fixed submission:
import math

a, b = (int(i) for i in input().split())  

 
answer = math.ceil((b-1)/(a-1))
print(answer)

Buggy submission (verdict: Runtime Error):
import math

a = input()
b = input()

answer = math.ceil((b-1)/(a-1))
print(answer)
Problem p02924 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int):
    answer = (N-1)*N//2
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n = input()
answer = 0
for i in range(1, n):
	answer += i

print(answer)
Problem p02936 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
from collections import deque

def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    matrix = [[] for _ in range(N+1)]
    counter = [0]*(N+1)
    for i in range(N-1):
        matrix[a[i]].append(b[i])
        matrix[b[i]].append(a[i])

    for q in range(Q):
        counter[p[q]]+=x[q]

    queue = deque()
    queue.append(1)

    checkflag = [False]*(N+1)
    while queue:
        root = queue.pop()
        checkflag[root]=True
        for node in matrix[root]:
            if checkflag[node] == False:
                queue.append(node)
                counter[node]+=counter[root]

    print(*counter[1:])




        
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    x = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import deque

def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):

    answer = [0]*N
    linked_list = [[] for _ in range(N)]
    for i in range(N-1):
        linked_list[a[i]-1].append(b[i]-1)
        linked_list[b[i]-1].append(a[i]-1)
    
    c = [0]*N
    is_Visited = [False]*N

    for j in range(Q):
        c[p[j]-1] += x[j]
    answer[0] = c[0]
    
    def dfs(node,counter):
        counter += c[node]
        is_Visited[node] = True
        for n in linked_list[node]:
            if is_Visited[n] == False:
                answer[n] = dfs(n,counter)
        
        return counter
        
    dfs(0,0)
    print(*answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    x = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)

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

Fixed submission:
#!/usr/bin/env python3
import sys
import collections
from itertools import groupby

def solve(N: int, s: "List[str]"):
    s = [sorted(s[i]) for i in range(N)]
    s.sort()
    group = groupby(s)
    answer = 0
    for key, group in group:
        a = len(list(group))
        answer += int(a*(a-1)/2) if a > 1 else 0
    print(answer)
   


    # for i in range(N):
    #     a = 1
    #     pop_index = []
    #     for j in range(i+1,len(ss)):
    #         if ss[i] == ss[j]:
    #             a += 1
    #             pop_index.append(j)
        
    #     ss = [ss[i] for i in range(len(ss)) if i not in pop_index]
    #     answer += int(a*(a-1)/2) if a > 1 else 0
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

N = int(input())
mojiretu = [input() for _ in range(N)]
dict = {}
answer = 0

for n in mojiretu:
  a = ''.join(sorted(list(n)))
  if a in dict.keys():
    dict[a]+=1
  else:
    dict[a]= 1

def fact(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n * fact(n-1) 
      
def nck(n,k):
  return int(fact(n)/(fact(n-k)*fact(k)))
      
for value in dict.values():
	if value > 1:
		answer += nck(value,2)

print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
mojiretu = [input() for _ in range(N)]
dict = {}
answer = 0

for n in mojiretu:
  a = ''.join(sorted(list(n)))
  if a in dict.keys():
    dict[a]+=1
  else:
    dict[a]= 1
 

def fact(n):
  if n == 0 or n == 1:
    return 1
  else:
    return n * fact(n-1)

  
for value in dict.values():
	if value > 1:
		answer += fact(value-1)

print(answer)
Problem p02975 (python)

Fixed submission:
import sys
from collections import Counter

N = int(input())
a = list(map(int,input().split()))
a.sort()
YES = 'Yes'
NO = 'No'
if a == [0]*N:
  print(YES)
  sys.exit()
  
if N%3 !=0:
  print(NO)
  sys.exit()
  
counter = Counter(a)
if len(counter) > 3:
  print(NO)
  sys.exit()
elif len(counter) == 3:
  if list(counter.values()) != [N//3,N//3,N//3]:
    print(NO)
  else:
    xor = 0
    for key in counter.keys():
      xor ^= key
    if xor == 0:
      print(YES)
    else:
      print(NO)
  sys.exit()
elif len(counter) == 2:
  if list(counter.keys())[0] == 0 and list(counter.values())[0] == N//3:
    print(YES)
  else:
    print(NO)
  sys.exit()

print(NO)

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter

N = int(input())
a = list(map(int,input().split()))
a.sort()
YES = 'Yes'
NO = 'No'
if a == [0]*N:
  print(Yes)
  sys.exit()
  
if N%3 !=0:
  print(NO)
  sys.exit()
  
counter = Counter(a)
if len(counter) > 3:
  print(NO)
  sys.exit()
elif len(counter) == 3:
  if list(counter.values()) != [N//3,N//3,N//3]:
    print(NO)
  else:
    xor = 0
    for key in counter.keys():
      xor ^= key
    if xor == 0:
      print(YES)
    else:
      print(NO)
  sys.exit()
elif len(counter) == 2:
  if counter.items[0][0] == 0 and counter.items[0][1] == N//3:
    print(YES)
  else:
    print(NO)
  sys.exit()

print(NO)
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())
answer = 2018

if r-l >= 2018:
  answer = 0
else:
  l = [i%2019 for i in range(l, r+1)]
  l.sort()
  for i in range(len(l)):
    for j in range(i+1, len(l)):
      answer = min(answer, l[i]*l[j]%2019)

print(answer)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
lr = [list(map(int,input().split())) for _ in range(m)]
min2 = 1
max2= n

for llrr in lr:
  min2 = max(min2, llrr[0])
  max2 = min(max2, llrr[1])

if max2-min2 >= 0:
  print(max2-min2+1)
else:
  print(0)
Problem p03325 (python)

Fixed submission:
import math
n = int(input())
a = list(map(int,input().split()))
maxlog = int(math.log2(max(a)))
answer = 0
for _ in range(maxlog):
  a = [aa/2 for aa in a if aa%2==0]
  answer+= len(a)
  if not a:
    break
print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
suuretu = [int(x) for x in input().split()]
answer = 0
 
for i in suuretu:
    answer += calculate(i)
 
def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1
    return a

print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
suuretu = [int(x) for x in input().split()]
answer = 0
 
for i in suuretu:
    answer += calculate(i)
 
def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1
    return a

print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
suuretu = [int(x) for x in input().split()]
answer = 0

for i in suuretu:
    answer += calculate(i)

def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1

    return a


print(answer)

Buggy submission (verdict: Runtime Error):
suuretu = [int(x) for x in input().split()]
answer = 0

for i in suuretu:
    answer += calculate(i)

def calculate(i):
    a = 0
    while i % 2 == 0:
        i = i / 2
        a += 1

    return a


print(answer)

Buggy submission (verdict: Runtime Error):
suuretu = [int(x) for x in input().split()]
answer = 0

for i in suuretu:
    answer += calculate(i)


def calculate(int):
    a = 0
    while int % 2 == 0:
        int = int / 2
        a += 1
    
    return a 

print(answer)

Buggy submission (verdict: Runtime Error):
suuretu = [int(x) for x in input().split()]
n = len(suuretu)
answer = 0

for i in suuretu:
    calculate(i)

def calculate(int):
    while int%2 == 0:
        int = int / 2
        answer += 1

print (answer)
Problem p03353 (python)

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]

  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(substrings) >= k:
    break
  

print(sorted(list(set(substrings)))[k-1])
Problem p03361 (python)

Fixed submission:
h,w = map(int,input().split())
cambus = [list(input()) for _ in range(h)]
import sys
for i in range(h):
  for j in range(w):
    if cambus[i][j]=="#":
      b = []
      if i != 0:
        b.append(cambus[i-1][j] == "#")
      if i != h-1:
        b.append(cambus[i+1][j] == "#")
      if j != 0:
        b.append(cambus[i][j-1] == "#")
      if j != w-1:
        b.append(cambus[i][j+1] == "#")

      if not any(b):
        print("No")
        sys.exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):
    s = ["."*(W+2)]+["."+ss+"."for ss in s]+["."*(W+2)]
    direction = ((0,1),(1,0),(0,-1),(-1,0))
    # 全ての黒マスの上下左右に一つでも黒マスがあればおk
    for i in range(H+2):
        for j in range(W+2):
            if s[i][j] == ".":
                continue
            
            for x,y in direction:
                if s[i+x][j+y] == "#":
                    break
            else:
                print(NO)
                return 
    
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()