Harryxun/stf_run huggingface dataset:
N = int(input())
x = int(input())
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
cage = sorted(cage)
ans=0

for i in range(N):
    n = cage[i]
    if x>=n:
        x = x - n
        ans += 1
    else:
        break

if cage[0]>x:
    ans=0
if x != 0:
    ans -= 1
print(ans)

### FIXED CODE ###

N, x = map(int, input().split())
A = list(map(int, input().split()))
 
x_tmp = x
for i, Ai in enumerate(sorted(A)):
    x_tmp -= Ai
    if x_tmp == 0:
        ans = i + 1
        break
    elif x_tmp < 0:
        ans = i
        break
    else: continue
else: ans = i
 
print(ans)
def gcd(a,b):
    a,b = (max(a,b),min(a,b))
    if a%b == 0:
        return b
    else:
        return gcd(a%b,b)

N = int(input())
A = list(map(int, input().split()))

L_gcd = [A[0]]
R_gcd = [A[-1]]

for i in range(1,N):
    L_gcd.append(gcd(L_gcd[i-1],A[i]))
    R_gcd.insert(0,gcd(A[N-i],R_gcd[A[N-i+1]]))

ans = max(L_gcd[-1],R_gcd[0])

for i in range(N-1):
    if gcd(L_gcd[i],R_gcd[i+2]):
        ans = gcd(L_gcd[i],R_gcd[i+2])
print(ans)

### FIXED CODE ###

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

N = int(input())
A = list(map(int, input().split()))

L_gcd = [0]*(N+1)
R_gcd = [0]*(N+1)

for i in range(N):
    L_gcd[i+1] = gcd(L_gcd[i],A[i])
    R_gcd[N-i-1] = gcd(R_gcd[N-i],A[N-i-1])

ans = 0
for i in range(N):
    if gcd(L_gcd[i],R_gcd[i+1])>ans:
        ans = gcd(L_gcd[i],R_gcd[i+1])
    
print(ans)
#??????????????????
N = int(raw_input())
num_list1 = raw_input().split()

num_list2 = num_list1


flag = 1
while flag==1:
    flag =0
    for j in range(N-1,0,-1):
        if int(num_list1[j][1:]) < int(num_list1[j-1][1:]):
            a = num_list1[j]
            num_list1[j] = num_list1[j-1]
            num_list1[j-1] = a
           
            flag =1

print " ".join(num_list1)
print "Stable"

#???????????????

for i in range(0,N,1):
   
    minj =i
    for j in range(i,N,1):
        if int(num_list2[j][1:]) < int(num_list2[minj][1:]):
            minj = j
            
    num_list2[i], num_list2[minj] = num_list2[minj], num_list2[i]
print " ".join(num_list2)


if num_list1 == num_list2: 
    print "Stable"
else:
    print "Not Stable"

### FIXED CODE ###


N = int(raw_input())
line = raw_input()

num_list1 = line.split()

num_list2 = line.split()


flag = 1
while flag==1:
    flag =0
    for j in range(N-1,0,-1):
        if int(num_list1[j][1:]) < int(num_list1[j-1][1:]):
            a = num_list1[j]
            num_list1[j] = num_list1[j-1]
            num_list1[j-1] = a
           
            flag =1

print " ".join(num_list1)
print "Stable"



for i in range(0,N,1):
   
    minj =i
    for j in range(i,N,1):
        if int(num_list2[j][1:]) < int(num_list2[minj][1:]):
            minj = j
            
    num_list2[i], num_list2[minj] = num_list2[minj], num_list2[i]
print " ".join(num_list2)


if num_list1 == num_list2: 
    print "Stable"
else:
    print "Not stable"
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = []
l = k.bit_length()
for i in range(l-1,-1,-1):
  if i == 0:
    x = k
  elif k & 1 << i:
    x = (k >> (i+1)) << i+1 | (1 << i)-1
  sm = 0
  for j in range(n):
    if a[j][0] | x == x:
      sm += a[j][1]
  ans.append(sm)
print(max(ans))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = [0]
l = max(k.bit_length(),1)
for i in range(l-1,-1,-1):
  if i == 0:
    x = k
  elif k & 1 << i:
    x = (k >> (i+1)) << i+1 | (1 << i)-1
  sm = 0
  for j in range(n):
    if a[j][0] | x == x:
      sm += a[j][1]
  ans.append(sm)
print(max(ans))
n = int(input())
s = int(input())

ans = float('inf')

for b in range(2, 10**6):
    res = n
    tmp = 0
    while res > 0:
        tmp += res % b
        res = (res-res % b)//b
    if tmp == s:
        ans = min(ans, b)

if n < 10**6:
    print(ans if ans != float('inf') else -1)
    exit()

for p in range(1, 10**6):
    if (n-s) % p != 0:
        continue
    else:
        b = (n-s)//p + 1
        if n % b == s-p:
            ans = min(ans, b)
        
print(ans if ans != float('inf') else -1)

### FIXED CODE ###

n = int(input())
s = int(input())

import math

ans = float('inf')

if s == n:
    print(n+1)
    exit()

for b in range(2, 10**6):
    res = n
    tmp = 0
    while res > 0:
        tmp += res % b
        res = (res-res % b)//b
    if tmp == s:
        ans = min(ans, b)

if n < 10**6:
    print(ans if ans != float('inf') else -1)
    exit()

for p in range(1, 10**6):
    if (n-s) % p != 0:
        continue
    else:
        b = (n-s)//p + 1
        if b > math.sqrt(n) and n % b == s-p:
            ans = min(ans, b)
        
print(ans if ans != float('inf') else -1)
#!/usr/bin/env python3
import math
#from functools import reduce

def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: v - X, x))

#    g = reduce(math.gcd, y)

    a = y.pop(0)
    while 0 < len(y):
        b = y.pop(0)
        a = math.gcd(a, b)

    print(a)


if __name__ == '__main__':
    main()



### FIXED CODE ###

#!/usr/bin/env python3
from functools import reduce

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while 0 < b:
        a, b = b, a % b
    return a


def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: abs(v - X), x))

    a = reduce(gcd, y)

    print(a)


if __name__ == '__main__':
    main()
import sys
X = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

for i in range(1000000000):
    C = X + (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), i)
        sys.exit()
    C = X - (i**5)
    if C**(1/5)%1 ==0:
        print(int(C**(1/5)), -i)
        sys.exit()


### FIXED CODE ###

X = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
A = [i**5 for i in range(200)]
B = [i**5 for i in range(200)]
# = [list(map(int, input().split())) for i in range(N)]

for i in range(200):
    for j in range(200):
        if A[i] + B[j] == X:
            print(int(A[i]**(1/5)), int(B[j]**(1/5)*(-1)))
            exit()
        if A[i] - B[j] == X:
            print(int(A[i]**(1/5)), int(B[j]**(1/5)))
            exit()
import numpy as np

n=int(input())
a=np.array(list(map(int,input().split())))
#print(a)

ans=0
for i in range(n):
  b=a[i]%a
  #print(b)
  #print(b==0)
  if np.count_nonzero(b==0)==1:
    ans+=1
print(ans)


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline()

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6+2)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6+2:
    cnt[x]+=1
    x+=a
for a in A:
  #print(cnt[a])
  if cnt[a]==1:
    ans+=1
print(ans)
a, b, c, x, y = map(int, input().split())
possible_minimum_sum1 = a * x + b * y
possible_minimum_sum2 = c * max(a, b) * 2
possible_minimum_sum3 = c * a * 2 + max(b-a, 0) * b
possible_minimum_sum4 = c * b * 2 + max(a-b, 0) * a

print(min(tuple(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3, possible_minimum_sum4)))


### FIXED CODE ###

a, b, c, x, y = map(int, input().split())
possible_minimum_sum1 = a * x + b * y
possible_minimum_sum2 = c * x * 2 + max(y-x, 0) * b
possible_minimum_sum3 = c * y * 2 + max(x-y, 0) * a

print(min(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3))
l=map(int,raw_input().split())

if l[0]>l[1]:
 print 'a > b'
elif l[1]>l[0]:
 print 'a < b'
else:
 print 'a == b

### FIXED CODE ###



l=map(int,raw_input().split())
 
if l[0]>l[1]:
 print 'a > b'
elif l[1]>l[0]:
 print 'a < b'
else:
 print 'a == b'
import random, string
def randomname(n):
   randlst = [random.choice(string.ascii_letters + string.digits) for i in range(n)]
   return ''.join(randlst)
S = input()
T = input()
l = len(T)
L = len(S)
before = randomname(l)
after = randomname(l)
for i in range(l):
   before[i] = '.'
   after[i] = '.'
S = before + S + after
max_ans = -1
for i in range(L+l+1):
   for j in range(l):
      ans = 0
      if T[j] == S[i + j]:
         ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)

### FIXED CODE ###


import random, string
S = input()
T = input()
l = len(T)
L = len(S)
max_ans = -1
for i in range(L):
   ans = 0
   if i + l > L:
      continue
   for j in range(l):
      if T[j] == S[i + j]:
            ans += 1
   max_ans = max(max_ans, ans)
print(l - max_ans)
import sys
import numpy as np

d = sys.stdin.readline()
while d:
    a,b,c,d,e,f = map(int,d.split())
    A = np.array([[a,b],[d,e]])
    B = np.array([c,f])
    x = np.linalg.inv(A).dot(B)
    print("%.3f %.3f"%(x[0],x[1]))

    d = sys.stdin.readline()

### FIXED CODE ###

import sys

d = sys.stdin.readline()
while d:
    a,b,c,d,e,f = map(int,d.split())
    inv = 1/(a*e - b*d)
    iA = [[e,-b],[-d,a]]
    B = [c,f]
    sol = list()
    for i in range(2):
        tmp = 0
        for j in range(2):
            tmp += inv*iA[i][j] * B[j]
        sol.append(tmp)
    print("%.3f %.3f"%(sol[0],sol[1]))

    d = sys.stdin.readline()
s = list(map(int,intput().split()))
s.sorted()

print(s[len(s)-1] - s[0])

### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
s.sort()

print(s[len(s)-1] - s[0])
import math

N,P = map(int,input().split())
A = list(map(int,input().split()))
pascal_triangle = []

memo = [[0 for _ in range(50)] for _ in range(50)]

def c(n,k):
  if memo[n][k] != 0:
      return memo[n][k]
  if(k<=0 or n<=k):
      memo[n][k] = 1
      return 1
  else:
      ans = c(n-1, k-1) + c(n-1, k)
      memo[n][k] = ans
      return ans

for i in range(50):
  pascal_triangle.append([c(i,j) for j in range(i+1)])

Numbers_1 = 0
for i in range(N):
    Numbers_1 += A[i] % 2

Select_0_count = sum(pascal_triangle[N - Numbers_1])

ans = 0

for i in range(Numbers_1+1):
    if i % 2 == P:
        ans += pascal_triangle[Numbers_1][i] * Select_0_count

print(ans)

### FIXED CODE ###

import math

N,P = map(int,input().split())
A = list(map(int,input().split()))
pascal_triangle = []

memo = [[0 for _ in range(51)] for _ in range(51)]

def c(n,k):
  if memo[n][k] != 0:
      return memo[n][k]
  if(k<=0 or n<=k):
      memo[n][k] = 1
      return 1
  else:
      ans = c(n-1, k-1) + c(n-1, k)
      memo[n][k] = ans
      return ans

for i in range(51):
  pascal_triangle.append([c(i,j) for j in range(i+1)])

Numbers_1 = 0
for i in range(N):
    Numbers_1 += A[i] % 2

Select_0_count = sum(pascal_triangle[N - Numbers_1])

ans = 0

for i in range(Numbers_1+1):
    if i % 2 == P:
        ans += pascal_triangle[Numbers_1][i] * Select_0_count

print(ans)
n=list(map(int,input()))
p=sum(n)
f=15
ans=(f-p)
print(ans)

### FIXED CODE ###

n=list(map(int,input().split()))
p=sum(n)
f=15
ans=(f-p)
print(ans)
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
P = [P[i] - 1 for i in range(N)]

loop_list = [] # ([indexes])
loop_score_list = []
loop_index_list = [0]*N
is_included_loop = [0] * N
num_loop = 0

for start in range(N):
    if is_included_loop[start]:
        continue
    now = start
    count = 1
    visited = [-1]*N # count
    visited[now] = 0
    while True:
        now = P[now]
        if visited[now] != -1:
            terminate_count = count
            start_count = visited[now]
            loop_start_idx = now
            break
        visited[now] = count
        count += 1
    
    num_loop += 1
    now = loop_start_idx
    loop_indexes = [now]
    visited = [-1]*N
    visited[now] = 0
    count = 1
    loop_score = 0
    while True:
        now = P[now]
        if visited[now] != -1:
            break
        loop_indexes.append(now)
        visited[now] = count
        loop_index_list[now] = num_loop
        loop_score += C[now]
        is_included_loop[now] = 1
    loop_list.append(loop_indexes)
    loop_score_list.append(loop_score)


scores = []
for start in range(N):
    tmp_score = 0
    rest = K
    now = start
    while not is_included_loop[now] and rest > 0:
        now = P[now]
        rest -= 1
        tmp_score += C[now]
        scores.append(tmp_score)
    
    if rest <= 0:
        scores.append(tmp_score)
        continue
    # loop
    number_of_loop = loop_index_list[now]
    one_cicle_score = loop_score_list[number_of_loop]
    if one_cicle_score < 0:
        continue
    if rest <= len(loop_list[number_of_loop]):
        while rest >= 0:
            now = P[now]
            rest -= 1
            tmp_score += C[now]
            scores.append(tmp_score)
        continue
    else:
        n_l = rest // len(loop_list[number_of_loop])
        tmp_score += n_l * one_cicle_score
        scores.append(tmp_score)
print(max(scores))
        
    

### FIXED CODE ###

INF = float("inf")

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -INF
for s in range(N):
    ### STEP1
    cum = []
    i = P[s] - 1 #s-> i
    cum.append(C[i])
    while i != s:
        i = P[i] - 1
        cum.append(cum[-1] + C[i])
    

    # STEP2
    if K <= len(cum):
        #1週未満しかできない
        score = max(cum[:K])
    
    elif cum[-1] <= 0:
        #一周以上できるが、ループしたら損する場合
        score = max(cum)
    else:
        # K//Length - 1回だけループし、最後は最適に止まる
        score1 = cum[-1] * (K//len(cum) - 1)
        score1 += max(cum)

        #ループをK//length回だけループする場合
        score2 = cum[-1]*(K//len(cum))
        resi = K % len(cum) #残り進める回数
        if resi != 0:
            #まだ進めるなら
            score2 += max(0, max(cum[:resi]))
        score = max(score1, score2)
    
    ans = max(ans, score)

print(ans)
n = int(input())
a = input()
p = 0
for i in range(n):
    if a[i] == "A":
        if a[i+1] == "B":
            if a[i+2] == "C":
                p += 1
print(p)

### FIXED CODE ###

n = int(input())
a = input()
p = 0
for i in range(n-2):
    if a[i] == "A":
        if a[i+1] == "B":
            if a[i+2] == "C":
                p += 1
print(p)
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left

def solve():
    # n, m = [int(x) for x in input().split()]
    s = [x for x in input()]
    a = s[:]
    k = int(input())
    if len(s) == 1:
        print(k // 2)
        return
    if len(set(s)) == 1:
        print((s * k)//2)
        return
    cnt = 0
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            s[i] = '.'
            cnt += 1

    cnt *= k
    
    if s[0] == s[-1] and s[0] != '.':
        cnt += (k - 1)

    print(min(cnt,ans))


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left

def solve():
    # n, m = [int(x) for x in input().split()]
    s = [x for x in input()]
    k = int(input())
    n = len(s)
    if len(set(s)) == 1:
        print(n*k//2)
        return
    b = [1]
    for i in range(1, n):
        if s[i] == s[i-1]:
            b[-1] += 1
        else:
            b.append(1)
    ans = 0
    for e in b:
        ans += e // 2 * k

    if s[0] == s[-1] and b[0] % 2 and b[-1] % 2:
        ans += k-1
    
    print(ans)


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""
N = int(input())
A = [int(n) for n in input().split()]

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        base = N if len(d) % 2 == 0 else N - 1
        ans = int(2 ** (base / 2)) % 1000000007
    else:
        ans = 0   
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
A = [int(n) for n in input().split()]

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        n = N if N % 2 == 0 else N - 1
        n //= 2
        ans = 1
        for _ in range(n):
            ans *= 2
            ans %= 1000000007
    else:
        ans = 0
    print(ans)

if __name__ == '__main__':
    main()
a, b =map(int,input().split())

answer = 1
num = 0
while(answer < b):
  anwer += a - 1
    num += 1
    
print(num)

### FIXED CODE ###

A, B = map(int, input().split())

ans = 1
i = 0
while ans < B:
    ans += A - 1
    i += 1

print(i)
X = input().split()
N = int(X[0])
M = int(X[1])
sc = []
 
 #リストscの[偶数]には桁、[奇数]には数字
for r in range(M):
  sc += input().split()

#scをint化
insect = [int(i) for i in sc]

k = 1
for r in range(N-1):
	k *= 10 
	ans = -1
#10^N以下について調べる
for r in range(k, k*10, 1):
	U = list(str(r))
	t = 0
	for s in range(M):
		if U[insect[2*s]-1] == str(insect[2*s+1]):
			t += 1
	if t == M:
		ans = r
		break

print(ans)

### FIXED CODE ###

X = input().split()
N = int(X[0])
M = int(X[1])
sc = []
 
 #リストscの[偶数]には桁、[奇数]には数字
for r in range(M):
  sc += input().split()

#scをint化
insect = [int(i) for i in sc]

#ループ開始の数字を10^(N-1)にセット
k = 1
for r in range(N-1):
	k = k*10

l = 10*k
ans = -1

if k == 1:
	k = 0
	
#k～10*k - 1について
for r in range(k, l, 1):

	#１文字ずつ見たいのでとりあえずリスト化
	U = list(str(r))
	t = 0

	#左から●番目の文字が▲と一致していれば t をインクリメント
	for s in range(M):
		if U[insect[2*s]-1] == str(insect[2*s+1]):
			t += 1
	#tが条件の数と一致したらansにそのときのrを代入し、ループから抜ける
	if t == M:
		ans = r
		break



#そのときのansの値を出力

print(ans)
N = int(input())
S = str(input())

posR = []
posG = []
posB = []

ctR = 0
ctG = 0
ctB = 0

for i in range(N):
    if S[i]=="R":
        posR.append(i)
        ctR += 1
    if S[i]=="G":
        posG.append(i)
        ctG += 1
    if S[i]=="B":
        posB.append(i)
        ctB += 1


def upper_bound(T,SSS):#スライスの値を返す。同じ値があったら右寄りに出す
    left = 0 #SSS[left]はTより真に小さい
    right = len(SSS)-1 #SSS[right]はTと同じかそれ以上

    if T<SSS[left]:
        return 0
    if T>=SSS[right]:
        return right+1

    while True:
        mid = (left+right)//2
        if right-left==1:
            return right
        if SSS[mid]<=T:
            left = mid
        else:
            right = mid


def calc(pos1,pos2,pos3):
    ct = 0
    for i in pos1:
        buff = upper_bound(i,pos2)
        for j in pos2[buff:]:#大丈夫？
            buff2 = upper_bound(j,pos3)
            ct += len(pos3)-buff2
            #print(i,j,len(pos3)-buff2)
            if 2*j-i in pos3:
                ct -= 1
    return ct

ans = 0
ans += calc(posR,posG,posB)
ans += calc(posR,posB,posG)
ans += calc(posG,posR,posB)
ans += calc(posG,posB,posR)
ans += calc(posB,posR,posG)
ans += calc(posB,posG,posR)
print(ans)


### FIXED CODE ###

N = int(input())
S = str(input())

r = S.count("R")
g = S.count("G")
b = S.count("B")

ct = r*g*b

for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k<=N-1:
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ct-=1
print(ct)
x = input()
 
if x in "753":
  print("Yes")
else:
  print("No"

### FIXED CODE ###

x = input()
 
if x in "753":
  print("YES")
else:
  print("NO")
S = str(input())

if S[3] == S[4] and S[5] == S[6]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = str(input())

if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")
if __name__ == '__main__':
    H, W = map(int, input().split())
    s_list = [list(input()) for i in range(H)]

    answer = "Yes"
    for i in range(H):
        for j in range(W):
            if s_list[i][j] == "#" and answer == "Yes":

                if i == 0:
                    if j == 0:
                        if s_list[i][j+1] == "." and s_list[i+1][j] == ".":
                            answer = "No"
                            break
                    elif j == W-1:
                        if s_list[i][j-1] == "." and s_list[i+1][j] == ".":
                            answer = "No"
                            break
                    else:
                        if s_list[i][j+1] == "." and s_list[i][j-1] == "." and s_list[i+1][j] == ".":
                            answer = "No"
                            break
                elif i == H - 1:
                    if s_list[i][j+1] == "." and s_list[i-1][j] == ".":
                            answer = "No"
                            break
                    elif j == W-1:
                        if s_list[i][j-1] == "." and s_list[i-1][j] == ".":
                            answer = "No"
                            break
                    else:
                        if s_list[i][j+1] == "." and s_list[i][j-1] == "." and s_list[i-1][j] == ".":
                            answer = "No"
                            break
                else:
                    if j == 0:
                        if s_list[i][j+1] == "." and s_list[i+1][j] == "." and s_list[i-1][j] == ".":
                            answer = "No"
                            break
                    elif j == W-1:
                        if s_list[i][j-1] == "." and s_list[i+1][j] == "." and s_list[i-1][j] == ".":
                            answer = "No"
                            break
                    else:
                        if s_list[i][j+1] == "." and s_list[i][j-1] == "." and s_list[i+1][j] == "." and s_list[i-1][j] == ".":
                            answer = "No"
                            break

    print(answer)

### FIXED CODE ###

if __name__ == '__main__':
    H, W = map(int, input().split())
    s_list = [list(input()) for i in range(H)]


    answer = "Yes"

    for x in range(H):
        for y in range(W):
            if s_list[x][y] == '.':
                continue
            is_all_white = True
            dxs = [0, 1, 0, -1]
            dys = [1, 0, -1, 0]
            for dx, dy in zip(dxs, dys):
                nx = x + dx
                ny = y + dy
                if 0 <= nx <= H-1 and 0 <= ny <= W-1:
                    if s_list[nx][ny] == "#":
                        is_all_white = False
                        break
            if is_all_white:
                answer = "No"
                break
        if s_list[x][y] == '#' and is_all_white:
            break

    print(answer)