Harryxun/stf_run huggingface dataset:
N, W = [int(item) for item in input().splite()]
lag = [[int(item) for item in input().splite()] for _ in range(N)]

dp = [0 for _ in range(N+1)]

for w in range(W+1):
  for i in range(N):
    if w + lag[i] <= W:
      dp[w+lag[i][0]] = max(dp[w], dp[w] + lag[i][1])

print(dp[N])

### FIXED CODE ###

N, W = [int(item) for item in input().split()]
item = [[int(item) for item in input().split()] for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if 0 <= w - item[i][0]:
            dp[i+1][w] = max(dp[i][w], dp[i][w - item[i][0]] + item[i][1])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])
n = int(input())
a = [int(input()) for _ in range(5)]
print(math.ceil(n/min(a))+4)

### FIXED CODE ###

import math
n = int(input())
tra = [int(input()) for i in range(5)]
print(math.ceil(n/min(tra))+4)
N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
else:
    NUM = 0
    LIST = [-1 for _ in range(N)]
    for s,c in S:
        s -= 1
        if(LIST[s]==-1):
            NUM += c*(10**(N-s-1))
            LIST[s] = c
        else:
            if(LIST[s]!=c):
                flag = 1
                print(-1)
                break
            else:
                continue
    if(LIST[0] == -1):
        if(N>1):
            NUM += 10**(N-1)
        else:
            NUM = 0
    elif(LIST[0] == 0):
        if(N>1):
            print(-1)
            flag = 1
        else:
            NUM = 0
    if(flag==0):
        print(NUM)

### FIXED CODE ###

N, M = [int(a) for a in input().split()]
S = [[int(i) for i in input().split()] for _ in range(M)]
flag = 0
NUM = 0
LIST = [-1 for _ in range(N)]
for s,c in S:
    s -= 1
    if(LIST[s]==-1):
        NUM += c*(10**(N-s-1))
        LIST[s] = c
    else:
        if(LIST[s]!=c):
            flag = 1
            print(-1)
            break
        else:
            continue
if(LIST[0] == -1):
    if(N>1):
        NUM += 10**(N-1)
    else:
        NUM = 0
elif(LIST[0] == 0):
    if(N>1):
        print(-1)
        flag = 1
    else:
        NUM = 0
if(flag==0):
    print(NUM)
def rec(n, a, seen):
	if seen[n-1]:
		return -1
	if a[n-1] == 2:
		return seen.count(True) + 1
	seen[n-1] = True
	return rec(a[n-1], a, seen)

def resolve():
	n = int(input())
	a = []
	seen = [False]*n
	for i in range(n):
		a.append(int(input()))
	print(rec(1, a, seen))
resolve()

### FIXED CODE ###

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10**6)

def rec(n, a, seen):
	if seen[n-1]:
		return -1
	if a[n-1] == 2:
		return seen.count(True) + 1
	seen[n-1] = True
	return rec(a[n-1], a, seen)

def resolve():
	n = int(input())
	a = []
	seen = [False]*n
	for _ in range(n):
		a.append(int(input()))
	print(rec(1, a, seen))
resolve()
from typing import List

n = int(input())
day, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
def choco(cday):
    sum = 0
    for i in range(day):
        if cday * i + 1 <= day:
           sum += 1
    return sum
csum = sum(list(map(choco, a))) + x
print(csum)


### FIXED CODE ###

n = int(input())
day, x = map(int, input().split())
a = [int(input()) for _ in range(n)]


def choco(cday):
    sum = 0
    for i in range(day):
        if cday * i + 1 <= day:
           sum += 1
    return sum


csum = sum(list(map(choco, a))) + x
print(csum)
S = list(map(int,input().split()))
len(S)=p
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t/2)


### FIXED CODE ###

S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))
N = int(input())
S = input()

prev = S[0]:

num = 1
for s in S[1:]:
    if prev != s:
        num += 1
    prev = s

print(num)

### FIXED CODE ###

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

prev = S[0]

num = 1
for s in S[1:]:
    if prev != s:
        num += 1
    prev = s

print(num)
a = int(input())
l = []
for i in range(a):
	t = int(input())
	l.append(t)
d=[False]*a

#a = 5
#l = [2,1,4,5,3]
used=[False]*(a+10)
res =0
for i in range(a):
	if not used[i] and i+1<a:
		f = l[i]
		#print(1,f)
		L = []
		L.append(f)
		res +=1
		used[l[i]] = True
		for j in range(i+1,a):
			if f < l[j] and not used[l[j]]:
				f = l[j]
				#print(f)
				L.append(f)
				used[l[j]] = True
		#print(L)
print(res)
				
				 
			

### FIXED CODE ###

#6484898
from bisect import bisect
N= int(input())
A = []
for i in range(N):
    t = int(input())
    A.append(t)

D = [1]*(N+1)
D[0] = -10**10
for a in A:
    idx = bisect(D, -a)
    D[idx] = min(D[idx], -a)
print(bisect(D, 0)-1)
A, B, C = map(int, input().split())
K = int(input())

biggest = max([A, B, C])
print(biggest * 2 ** K + sum(A, B, C) - biggest)

### FIXED CODE ###

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

biggest = max(A, B, C)
print(biggest * 2 ** K + sum([A, B, C]) - biggest)
import numpy as np

n, l = [int(i) for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(np.min(np.absolute(ll)))
lll = ll.pop(mini)

print(np.sum(lll))


### FIXED CODE ###

import numpy as np

n, l = [int(i) for i in input().split(" ")]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = np.where(np.absolute(ll) == np.min(np.absolute(ll)))
ll = list(ll)
del ll[mini[0][0]]

print(np.sum(ll))
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    else:
        while (j * j <= x):
            if (x % j == 0):
                break
            else:
                count += 1
print(count)
 

### FIXED CODE ###

n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    elif (x % 2 == 0):
        continue
    else:
        if (pow(2, x - 1, x) == 1):
            count += 1
print(count)
i = 0
max = 0
min = 100000000
ave = 0
x = int(input())
for i in range(0, x):
    a = int(input())
    if(max < a):
        max = a
    if(min > a):
        min = a
    avg += a
print("%d %d %d"%(min, max, ave//x))


### FIXED CODE ###

x = input()
a = list(map(int, input().split()))
print("%d %d %d"%(min(a), max(a), sum(a)))
x=input()
n=[x[i] for i in range(len(n))]
for i in range(len(n)):
  if n[i]=="1"or"9":
    if n[i]=="1":
      n[i]="9"
    else:
      n[i]=="1"
print(int("".join(n)))

### FIXED CODE ###

x=input()
n=[x[i] for i in range(len(x))]
for i in range(len(n)):
  if n[i]=="1":
    n[i]="9"
  elif n[i]=="9":
    n[i]="1"
print(int("".join(n)))
a,b=int(input())
if (a+b)%2==0:
    print((a+b)/2)
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

a,b=map(int,input().split())
if (a+b)%2==0:
    print((a+b)//2)
else:
    print("IMPOSSIBLE")
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	for j in reversed(range(n-1)):
  		if k < a[i] - a[j]:
  			ans = ":( ";
  			break;

print ans;

### FIXED CODE ###

n = 6;
a = [input() for i in range(n)];
 
k = a[-1];
ans = "Yay!";
 
for i in range(n-1):
  for j in reversed(range(n-1)):
    if k < a[i] - a[j]:
      ans = ":( ";
      break;
print ans;
N = int(input())
A_list = []
for i in range(1,N+1):
    A = int(input())
    A_list.append([i,A])

pop_que =[]

for i in range(N):
    pop_que =A_list.pop(0)
    pop_que.append(max(A_list,key=lambda x:x[1]))
    A_list.append(pop_que)

for i in range(N):
    print(f"{A_list[i][2][1]}")


### FIXED CODE ###

N = int(input())
A_list = []
for i in range(1,N+1):
    A = int(input())
    A_list.append(A)
A_list_sort = sorted(A_list)

max_a = A_list_sort[-1]
max_b = A_list_sort[-2]


for i in range(N):
    if A_list[i] == max_a:
        print(max_b)
    else:
        print(max_a)
import numpy as np
while True:
    num = int(input())
    if num == 0:
        break
    data = np.array(list(map(int, input().split())))
    print(np.std(data))


### FIXED CODE ###

while True:
    num = int(input())
    if num == 0:
        break
    data = list(map(int, input().split()))
    datasqr = [i ** 2 for i in data]
    print("%lf" % (sum(datasqr) / num - (sum(data) / num) ** 2) ** 0.5)
a = map(float, input().split())
print(f'{a * a * 3.1415926}')
print(f'{2 * a * 3.1415926}')



### FIXED CODE ###

r = float(input())
p = 3.141592653589
print(p*r*r, 2*p*r)
all = list(map(int, input().split()))

N = all[0]
Y = all[1]

yu = -1
hi = -1
no = -1
for i in range(N):
    for j in range(N-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y!=total:
            continue
        else:
            yu = i
            hi = j
            no = c
            check += 1
            break
    else:
        continue 
    break

print(yu)
print(" ")
print(hi)
print(" ")
print(no)
print(" ")


### FIXED CODE ###

all = list(map(int, input().split()))

N = all[0]
Y = all[1]

yu = -1
hi = -1
no = -1
for i in range(N+1):
    for j in range((N+1)-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y==total:
            yu = i
            hi = j
            no = c
            break
        else:
            continue
    else:
        continue 
    break

print(str(yu) + " " + str(hi) + " " + str(no))
#include <stdio.h>

int main()
{
  int n, m;
  
  scanf("%d", &n);
  scanf("%d", &m);
  
  if (n == m)
  	printf("Yes\n");
  else
    printf("No\n");
}

### FIXED CODE ###

r = input()
k=r.split()
if k[0] == k[1]:
    print('Yes')
else:
    print('No')
# input
N = int(input())
SA = [str(input()) for i in range(N)]

# process
cities = list(set([x.split()[0] for x in SA]))
cities.sort()

for y in cities:
    each_SA = [i for i in SA if y in i]
    each_points = [int(x.split()[1]) for x in each_SA]
    each_points.sort(reverse=True)
    for j in each_points:
        print(SA.index(y + ' ' + str(j)) + 1)


### FIXED CODE ###

# input
N = int(input())
SA = [str(input()) for i in range(N)]

# process
cities = list(set([x.split()[0] for x in SA]))
cities.sort()

for y in cities:
    each_SA = []
    for i in SA:
        if i.split()[0] == y:
            each_SA.append(i)
    each_points = [int(x.split()[1]) for x in each_SA]
    each_points.sort(reverse=True)
    for j in each_points:
        print(SA.index(y + ' ' + str(j)) + 1)
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]
T = max(stc, key=lambda x:x[1])[1]
record = [[0]*(T+2) for _ in range(c+1)]
for s, t, c in stc:
    record[c][s] += 1
    record[c][t] -= 1

for r in record:
    for i in range(T+3):
        r[i+1] += r[i]

for s, t, c in stc:
    record[c][s-1] += 1

ans = 0
for i in range(T+3):
    y = 0
    for r in record:
        y += r[i]
    ans = max(ans, y)
print(ans)

### FIXED CODE ###

n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]
T = 10**5+1
record = [[0]*(T+3) for _ in range(c+1)]
channel = [[] for _ in range(c+1)]
stc.sort()

for s, t, c in stc:
    if not channel[c]:
        channel[c].append([s - 1, t])
        continue
    if channel[c][-1][1] == s:
        channel[c][-1][1] = t
    else:
        channel[c].append([s-1, t])

for i, v in enumerate(channel):
    for s, t in v:
        record[i][s] += 1
        record[i][t] -= 1

for i in record:
    for j in range(T+2):
        i[j+1] += i[j]

ans = 0
for i in range(T+2):
    y = 0
    for r in record:
        y += r[i]
    ans = max(ans, y)
print(ans)
def main():
    
    n = int(input())

    n_list = []
    for i in range(n):
        a_list = []
        a = int(input())
        for j in range(a):
            x,y = map(int, input().split())
            x -= 1
            a_list.append([x,y])
        if a == 0:
            a_list.append([0])
        n_list.append(a_list)

    #print(n_list)
    ans = [0]
    for j in range(0,2**n):
        tmp = bin(j)
        tmp = str(int(tmp[2:])).zfill(n)
        #print('tmp')
        #print(tmp)
        
        
        break_on = 0
        for k in range(n):
            if tmp[k] == '1':
                if n_list[k][0] != 0:
                    for h in n_list[k]:
                        #print('########')
                        #print(k)
                        #print(h[1])
                        #print(tmp[h[0]])
                        if h[1] != int(tmp[h[0]]):
                            break_on = 1
                            break
                    if break_on == 1:
                        break
            if break_on == 1:
                break
            
            if tmp[k] == '0':
                continue
        
        if break_on == 0:
            #print('tmp.count()')
            #print(tmp.count('1'))
            ans.append(tmp.count('1'))
    
    #print(ans)
    print(max(ans))
    


            



if __name__ == '__main__':
    main()



### FIXED CODE ###


def main():
    
    n = int(input())

    n_list = []
    for i in range(n):
        a_list = []
        a = int(input())
        for j in range(a):
            x,y = map(int, input().split())
            x -= 1
            a_list.append([x,y])
        if a == 0:
            a_list.append([0])
        n_list.append(a_list)

    #print(n_list)
    ans = [0]
    for j in range(0,2**n):
        tmp = bin(j)
        tmp = str(int(tmp[2:])).zfill(n)
        #print('tmp')
        #print(tmp)
        
        
        break_on = 0
        for k in range(n):
            if tmp[k] == '1':
                #print(n_list[k])
                if n_list[k][0] != [0]:
                    for h in n_list[k]:
                        #print('########')
                        #print(k)
                        #print(h[1])
                        #print(tmp[h[0]])
                        if h[1] != int(tmp[h[0]]):
                            break_on = 1
                            break
                    if break_on == 1:
                        break
            if break_on == 1:
                break
            
            if tmp[k] == '0':
                continue
        
        if break_on == 0:
            #print('tmp.count()')
            #print(tmp.count('1'))
            ans.append(tmp.count('1'))
    
    #print(ans)
    print(max(ans))
    


            



if __name__ == '__main__':
    main()
n = input()

color = [0 for i in range(n)]
d = [0 for i in range(n)]
f = [0 for i in range(n)]
M = [0 for i in range(n)]0 for j in range(n)]
t = 0

def dfs_v(u):
  color[u] = 1
  t += 1
  d[u] = t
  for v in range(n):
    if M[u][v] == 1 and color[v] == 0:
      dfs_v(v)
  color[u] = 2
  t += 1
  f[u] = t

def dfs():
  for u in range(n):
    if color[u] == 0:
      dfs_v(u)
  for u in range(n):
    print u+1, d[u], f[u]

for i in range(n):
  X = map(int, raw_input().split())
  for j in range(X[1]):
    M[X[0]-1] [X[2+j]-1] = 1

dfs()
    

### FIXED CODE ###

n = int(raw_input())
 
d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
col = [0 for i in range(n)]
t = [0]
 
def DFS_visit(u):
    col[u] = 1
    t[0] += 1
    d[u] = t[0]
    for v in range(n):
        if M[u][v] == 1 and col[v] == 0:
            DFS_visit(v)
    col[u] = 2
    t[0] += 1
    f[u] = t[0]
 
def DFS():
    for u in range(n):
        if col[u] == 0:
            DFS_visit(u)
    for u in range(n):
        print'{0} {1} {2}'.format(u+1, d[u], f[u])
     
for i in range(n):
    X = map(int, raw_input().split())
    for j in range(X[1]):
        M[X[0]-1][X[2+j]-1] = 1
 
DFS()
from itertools import combinations


def read_input():
    s = input().strip()
    return s

def split_and_sum(s, indice):
    indice_e = [0, *indice, 10]

    result = []
    for start,end in zip(indice_e, indice_e[1:]):
        result.append(int(s[start:end]))

    return sum(result)

def submit():
    s = read_input()
    max_index = len(s)

    acc = 0
    for i in range(max_index):
        for c in combinations(range(1, max_index), i):
            acc += split_and_sum(s, c)

    print(acc)

if __name__ == '__main__':
    submit()

### FIXED CODE ###


from itertools import combinations


def read_input():
    s = input().strip()
    return s

def split_and_sum(s, indice):
    indice_e = [0] + indice + [10]

    result = []
    for start,end in zip(indice_e, indice_e[1:]):
        result.append(int(s[start:end]))

    return sum(result)

def submit():
    s = read_input()
    max_index = len(s)

    acc = 0
    for i in range(max_index):
        for c in combinations(range(1, max_index), i):
            acc += split_and_sum(s, list(c))

    print(acc)

if __name__ == '__main__':
    submit()
N = int(input())
X = list(map(int, input().split()))

avg = sum(X)//N

E1 = sum(list(map(lambda x: (x - avg)**2, X)))
E2 = sum(list(map(lambda x: (x - avg - 1)**2, X)))

print(min(E1m E2))

### FIXED CODE ###

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

avg = sum(X)//N

E1 = sum(list(map(lambda x: (x - avg)**2, X)))
E2 = sum(list(map(lambda x: (x - avg - 1)**2, X)))

print(min(E1,E2))
n, k = map(int, raw_input().split())
A = [int(raw_input())-k for i in xrange(n)]
su = 0
v = [(0, 0)]
for i in xrange(n):
    su += A[i]
    v.append((su, i+1))
v.sort()

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*n
        self.el = [0]*n
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i):
        return self.el[i]

ans = 0
bit = BIT(n+2)
for e, i in v:
    ans += bit.sum(i+1)
    bit.add(i+1, 1)
print ans

### FIXED CODE ###

n, k = map(int, raw_input().split())
A = [int(raw_input())-k for i in xrange(n)]
su = 0
v = [(0, 0)]
for i in xrange(n):
    su += A[i]
    v.append((su, i+1))
v.sort()

data = [0]*(n+5)
def dsum(i):
    s = 0
    while i > 0:
        s += data[i]
        i -= i & -i
    return s
def add(i, x):
    while i <= n+2:
        data[i] += x
        i += i & -i
ans = 0
for e, i in v:
    ans += dsum(i+1)
    add(i+1, 1)
print ans
n,k=map(int, input().split())
an=[int(i) for i in input().split()]
from scipy.special import comb

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    max1+=an[-i]*comb(n-i,k-1,exact=True)
    min1+=r_an[-i]*comb(n-i,k-1,exact=True)
print((max1-min1)%(10**9+7))

### FIXED CODE ###

n,k=map(int, input().split())
an=[int(i) for i in input().split()]

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r=min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2,N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    c=cmb(n-i,k-1,p)
    max1=max1 + an[-i]*c%p
    min1=min1 + r_an[-i]*c%p
print((max1-min1)%p)
from bisect import bisect_left as bl

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    if M in A:
        print(*[A[-1],M])
        exit()
    if k == N-1:
        ans = [A[-1],A[k-1]]
        print(*ans)
        exit()
    if k == 0:
        print(*[A[-1],A[0]])
        exit()
    if N == 2:
        print(*reversed(A))
        exit()
    if abs(A[k-1]-M) < abs(M-A[k]) and abs(A[k-1]-M) < abs(A[k+1]-M):
        ans = [A[-1],A[k-1]]
    elif abs(A[k+1]-M) < abs(M-A[k]) and abs(A[k+1]-M) < abs(A[k-1]-M):
        ans = [A[-1],A[k+1]]
    elif abs(A[k-1]-M) > abs(M-A[k]) and abs(A[k]-M) < abs(A[k+1]-M):
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from bisect import bisect_left as bl

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    if M in A:
        print(*[A[-1],M])
        exit()
    if k == N-1:
        ans = [A[-1],A[k-1]]
        print(*ans)
        exit()
    if k == 0:
        print(*[A[-1],A[0]])
        exit()
    if A[-1]%2 == 0:
        if abs(A[k-1]-M) <= abs(M-A[k]) and abs(A[k-1]-M) <= abs(A[k+1]-M):
            ans = [A[-1],A[k-1]]
        elif abs(A[k+1]-M) <= abs(M-A[k]) and abs(A[k+1]-M) <= abs(A[k-1]-M):
            ans = [A[-1],A[k+1]]
        elif abs(A[k]-M) <= abs(M-A[k-1]) and abs(A[k]-M) <= abs(A[k+1]-M):
            ans = [A[-1],A[k]]
    else:
        if abs(A[k-1]-M) < abs(M-A[k]) and abs(A[k-1]-M) < abs(A[k+1]-M):
            ans = [A[-1],A[k-1]]
        elif abs(A[k+1]-M) <= abs(M-A[k]) and abs(A[k+1]-M) <= abs(A[k-1]-M):
            ans = [A[-1],A[k+1]]
        elif abs(A[k]-M) <= abs(M-A[k-1]) and abs(A[k]-M) <= abs(A[k+1]-M):
            ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()
N = int(input())
A = list(map(int, input().split()))

count = 0

def dfs(x, y):
    global count
    if x >= N or y >= N:
        return
    
    if (A[x]+A[y]) == y-x:
        count += 1
    
    if y+1 >= N:
        dfs(x+1, x+2)
    else:
        dfs(x, y+1)


dfs(0, 1)

print(count)


### FIXED CODE ###

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

count = 0

def solve():
    from collections import Counter
    cc=Counter()
    ans=0
    for i,val in enumerate(A,1):
        if i-val>0:
            ans+=cc[i-val]
        cc[i+val]+=1
    print(ans)
    
def dfs(x, y):
    global count
    if x >= N or y >= N:
        return
    
    if (A[x]+A[y]) == y-x:
        count += 1

    if x+1 >= N and y+1 >= N:
        return
        
    if y+1 >= N:
        dfs(x+1, x+2)
    else:
        dfs(x, y+1)


#dfs(0, 1)
#print(count)
solve()
h,w=map(int,input().split())
mass=[]
f=0
for i in range(0,h):
    mass.append(list(input()))
for i in range(h):
    if f==0:
        for j in range(w-1):
            if i!=h and j!=w:
                if mass[i][j]=="#" and mass[i][j]!=mass[i][j+1] and mass[i][j]!=mass[i+1][j]:
                    f=1
                    break
            elif i==h:
                if mass[i][j]=="#" and mass[i][j]!=mass[i][j+1]:
                    f=1
                    break
            else:
                if mass[i][j]=="#" and mass[i][j]!=mass[i+1][j]:
                    f=1
                    break
if f==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

h,w=map(int,input().split())
mass=[]
f=0
frame=[["."]*(w+2) for i in range(h+2)]
for i in range(h):
    mass.append(list(input()))
for i in range(h):
    for j in range(w):
        frame[i+1][j+1]=mass[i][j]
for i in range(1,h):
    if f==0:
        for j in range(1,w):
            if frame[i][j]=="#" and frame[i][j]!=frame[i][j+1] and frame[i][j]!=frame[i+1][j] and frame[i][j]!=frame[i][j-1] and frame[i][j]!=frame[i-1][j]:
                    f=1
                    break
if f==0:
    print("Yes")
else:
    print("No")