Harryxun/stf_run huggingface dataset:
from collections import deque
s = list(input())
q_num = int(input())

s_deq = deque(s)
reversed = False

for _ in range(q_num):
    query = input().split()
    if query[0] == '1':
        reversed = False if reversed else True
    elif query[0] == '2':
        if not reversed:
            if query[1] == '1':
                s_deq.insert(0, query[2])
            elif query[1] == '2':
                s_deq.append(query[2])
        else:
            if query[1] == '2':
                s_deq.insert(0, query[2])
            elif query[1] == '1':
                s_deq.append(query[2])
if reversed:
    s_deq.reverse()
print(''.join(s_deq))

### FIXED CODE ###

from collections import deque
s = list(input())
q_num = int(input())

s_deq = deque(s)
reversed = False

for _ in range(q_num):
    query = input().split()
    if query[0] == '1':
        reversed = False if reversed else True
    elif query[0] == '2':
        if not reversed:
            if query[1] == '1':
                s_deq.appendleft(query[2])
            elif query[1] == '2':
                s_deq.append(query[2])
        else:
            if query[1] == '2':
                s_deq.appendleft(query[2])
            elif query[1] == '1':
                s_deq.append(query[2])
if reversed:
    s_deq.reverse()
print(''.join(s_deq))
import math
N, K = list(map(int, input().split()))
A = list(map(int, input().split())) #A[0]〜A[N-1]

m = min(A)
answer = N

for i in range(N-K+1): #A[i:i+K]〜A[N-K:N]
  if not k in A[i:i+K]:
    continue
  answer = min(answer,
              (1 + math.ceil(i/(K-1)) + math.ceil((N-K-i)/(K-1))))
print(answer)

### FIXED CODE ###

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

print((N-1)//(K-1) + bool((N-1)%(K-1)))
input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
C = []
for _ in range(m):
    b, c = map(int, input().split())
    for i in range(b):
        C.append(c)
A.extend(C)

A = sorted(A, reverse=True)
result = [A[i] for i in range(n)]
print(sum(result))

### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

maxi = n*2
extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC if len(A) <= maxi]
A.sort(reverse=True)

print(sum(A[:n]))
s=input()
t=s[::-1]
n=len(input())
if n%2==0:
    x=n//2
else:
    x=(n-1)//2
count=0
    for i in range(x):
        if s[i]!=t[i]:
            count+=1
prnt(count)

### FIXED CODE ###

s=input()
n=len(s)
cnt=0
if n%2==0:
  for i in range(n//2):
    if s[:n//2][::-1][i]!=s[n//2:n][i]:
      cnt+=1
  print(cnt)
else:
  for i in range(n//2):
    if s[:(n-1)//2][::-1][i]!=s[(n+1)//2:n][i]:
      cnt+=1
  print(cnt)
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,t = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    d = []
    u = []
    pv = 1000000
    for i in range(n-1):
        if pv > a[i] < a[i+1]:
            d.append(a[i])
        elif pv < a[i] > a[i+1]:
            u.append(a[i])
        if a[i] != a[i+1]:
            pv = a[i]

    if pv < a[-1]:
        u.append(a[-1])

    ds = []
    if len(u) != len(d):
        print(asdasd)
    for ui,di in zip(u,d):
        ds.append(ui-di)
    dma = max(ds)
    cnt = 0
    for i in ds:
        if dma == i:
            cnt += 1
    print(cnt)
    return None

if __name__ == '__main__':
    main()


### FIXED CODE ###

'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,t = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    bs = []
    mi = a[0]
    for i in a[1::]:
        if mi < i:
            bs.append(i-mi)
        else:
            mi = i
    ma = max(bs)
    cnt = 0
    for i in bs:
        if i == ma:
            cnt += 1

    print(cnt)
    return None

if __name__ == '__main__':
    main()
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i == N-1:
        if P[i] == i+1:
            ans +=1
    a, b = P[i], P[i + 1]
    if a == i + 1:
        ans += 1
        P[i] = b
        P[i + 1] = a
print(ans)


### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i == N-1:
        if P[i] == i+1:
            ans +=1
        break
    a, b = P[i], P[i + 1]
    if a == i + 1:
        ans += 1
        P[i] = b
        P[i + 1] = a
print(ans)
X, A = map(int, input().spilt())

if X < A:
    print(0)
else:
    print(10)

### FIXED CODE ###

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

if X < A:
    print(0)
else:
    print(10)
def main():
    S = list(input())
    T = list(input())

    for i in range(len(S)-len(T)+1):
        ans = ""
        for j in range(i):
            if S[j] == "?":
                ans += "a"
            else:
                ans += S[j]

        for j in range(i, len(S)):
            if S[j] == T[j-i]:
                ans += S[j]
            elif S[j] == "?":
                ans += T[j-i]
            else:
                break

        if len(ans) == len(S):
            print(ans)
            exit()
            
    print("UNRESTORABLE")

if __name__ == "__main__":
    main()

### FIXED CODE ###

S = input()
T = input()

def f():
    l = []
    for i in range(len(S)):
        if i + len(T) > len(S):
            break
        flag = True
        for j in range(len(T)):
            if S[i + j] not in [T[j], "?"] :
                flag = False
                break
        if flag:
            s = S
            s = s[:i] + T + s[i+len(T):]
            s = s.replace("?", "a")
            l.append(s)
    l.sort()
    if len(l):
        return l[0]
    else:
        return "UNRESTORABLE"

print(f())
N, M = map(int,input().split())
crain = (4 * N - M) / 2
if crain.is_integer():
  if crain >= 0　and (N - int(crain)) > 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")


### FIXED CODE ###

import sys
x,y = map(int,input().split())
for i in range(x+1):
  for j in range(x-i+1):
    if i+j == x and (i*2)+(j*4) == y:
      print("Yes")
      sys.exit()
print("No")
N = int(input())

ans = 0
for i in range(1,N+1):
    if i % 3==0 or i % 5 ==0:
        continue
    ans += i

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

ans = 0
for i in range(1,N+1):
    if i % 3==0 or i % 5 ==0:
        continue
    ans += i

print(ans)

### FIXED CODE ###

N = int(input())

ans = 0
for i in range(1, N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ans += i

print(ans)
# -*- coding; utf-8 -*-
H,W = map(int,input().split())
a = []
for i in range(H):
  a.append(map(str,input().split()))
print("#####")
while i < H:
  print("#"+str(a[i])+"#")
  i=i+1
print("#####")

### FIXED CODE ###

# -*- coding: utf-8 -*-
x,y = map(int,input().split())
A = {1,3,5,7,8,10,12}
B = {4,6,9,11}
C = {2}
S = {x,y}
if (S <= A or S <= B) is True:
  print("Yes")
else:
  print("No")
N = int(input())
cap = [int(input()) for i in range(5)]
state = [N, 0, 0, 0, 0, 0]
time = 0
while state[-1] != N:
    for i in range(4,-1,-1):
        if state[i]==0:
            continue
        move = cap if state[i]>=cap[i] else state[i]
        state[i] -= move
        state[i+1] += move
    time += 1
print(time)

### FIXED CODE ###

import math
N = int(input())
cap = [int(input()) for i in range(5)]
print( math.ceil(N/min(cap))+4)
while True:
    n, r = map(int, input().split())
    if n == 0 and r == 0:
        break

    l = []
    for i in range(1, n + 1):
        l.append(i)

    for i in range(0, r):
        p, c = map(int, input().split())
        tmp = l[len(l) - p + 1:len(l)]
        del l[len(l) - p + 1:len(l)]
        l[len(l) - c:len(l) - c] = tmp

    print(l[len(l) - 1])

### FIXED CODE ###

while True:
    n, r = map(int, raw_input().split())
    if n == 0 and r == 0:
        break

    l = range(n, 0, -1)

    for i in range(r):
        tmp = []
        p, c = map(int, raw_input().split())
        for j in range(c):
            tmp.append(l.pop(p - 1))
        l = tmp + l
    print l[0]
i = 0
w = raw_input()
while True:
	t = raw_input()
	if t == 'END_OF_FILE':
		break
	else: 
		i += t.strip('.').split().count(w)
print i

### FIXED CODE ###

i = 0
w = raw_input().upper()
while True:
	t = raw_input()
	if t == 'END_OF_TEXT':
		break
	else: 
		i += t.upper().strip('.').split().count(w)
print i
from heapq import heappush, heappop
from operator import itemgetter
N, K = map(int, input().split())
x = list(map(int, input().split()))
t = []
for i in range(K):
    ta, tb = map(int, input().split())
    t.append([ta,tb]) 
a = sorted(t, key=itemgetter(1))
x.sort()
x = x[::-1]
s = 0
l = []
while x or a:
    if a[-1][0] == 0:a.pop()
    if not a:
        s+=sum(x)
        break
    r = x.pop()
    if r < a[-1][1]:
        s+=a[-1][1]
        a[-1][0]-=1
    else:
        s+=sum(x)+r
        break
print(s)

### FIXED CODE ###

from heapq import heappush, heappop
from operator import itemgetter
N, K = map(int, input().split())
x = list(map(int, input().split()))
t = []
for i in range(K):
    ta, tb = map(int, input().split())
    t.append([ta,tb]) 
a = sorted(t, key=itemgetter(1))
x.sort()
x = x[::-1]
s = 0
l = []
while x or a:
    if a[-1][0] == 0:a.pop()
    if not a:
        s+=sum(x)
        break
    if len(x) ==0:break
    r = x.pop()
    if r < a[-1][1]:
        s+=a[-1][1]
        a[-1][0]-=1
    else:
        s+=sum(x)+r
        break
print(s)
n, a, b = map(int, input().split())
mod = 10**9+7
def Pow(a, n):
    if n == 0: return 1
    if n%2 == 0:
        return (Pow(a, n//2))**2%mod
    else:
        return Pow(a, n-1)*a%mod
cnt = Pow(2, n) - 1
x = [0] * (n+1)
for i in range(1,b+1):
    x[i] = Pow(i, mod-2)
cmb = [0] * (n+1)
cmb[1] = n
for i in range(2, b+1):
    cmb[i] = cmb[i-1]*(n-i+1)%mod*x[i]%mod
cnt -= cmb[a]+cmb[b]
print(cnt%mod)

### FIXED CODE ###

n, a, b = map(int, input().split())
mod = 10**9+7
def Pow(a, n):
    fac = a
    res = 1
    for i in range(len(bin(n)[2:])):
        if n&1:
            res = res*fac%mod
        fac = fac*fac%mod
        n = n>>1
    return res
cnt = Pow(2, n) - 1
x = [0] * (b+1)
for i in range(1,b+1):
    x[i] = Pow(i, mod-2)
cmb = [0] * (b+1)
cmb[1] = n
for i in range(2, b+1):
    cmb[i] = cmb[i-1]*(n-i+1)%mod*x[i]%mod
cnt -= cmb[a]+cmb[b]
print(cnt%mod)
import sys

def main():
    args = sys.argv
    if int(args[1]) <= int(args[2]):
        print("unsafe")
    else:
        print("safe")

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    num = input().split()
    if int(num[0]) <= int(num[1]):
        print("unsafe")
    else:
        print("safe")

if __name__ == "__main__":
    main()
n,k=map(int,input().split())
p=list(map(int,input().split()))

e=[0]*n

for i in range(n):
  e[i]=(1+p[i])/2
  if i!=0:
    e[i]+=e[i-1]

arr=[]

for i in range(k,n):
  s=i-k
  arr.append(e[i]-e[s])

print(max(arr))

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))

e=[0]*n

for i in range(n):
  e[i]=(1+p[i])/2
  if i!=0:
    e[i]+=e[i-1]

arr=[]

if n==k:
  print(e[-1])
  exit()

for i in range(k,n):
  s=i-k
  arr.append(e[i]-e[s])

print(max(arr))
import math

def x(k, c, d):
    rl1 = k
    lcm = c*d / math.gcd(c,d)
    ccount = int(rl1 // c)
    dcount = int(rl1 // d)
    if lcm != 0:
        cdcount = int(rl1 // lcm)
    else:
        cdcount = 0
        

    return int(rl1 - ccount - dcount + cdcount)

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

print(x(b, C, D) - x(a-1, C, D))

### FIXED CODE ###

import fractions

def x(k, c, d):
    rl1 = k
    lcm = c*d // fractions.gcd(c,d)
    ccount = rl1 // c
    dcount = rl1 // d
    cdcount = rl1 // lcm
    # if lcm != 0:
    #     cdcount = int(rl1 // lcm)
    # else:
    #     cdcount = 0

    return rl1 - ccount - dcount + cdcount

a, b, C, D = map(int, input().split())
print(x(b, C, D) - x(a-1, C, D))
def color(r):
  if r<3200:return r//400
  else:return 8
colors = [0]*9
N=int(input())
for a in map(int,input().split()):
  colors[color(a)]+=1
base=0
for i n range(8):
  if colors[i]>0:base+=1
print(base, base+colors[8])

### FIXED CODE ###

c=[0]*9
input()
for a in map(int,input().split()):c[min(a//400,8)]+=1
b=0
for i in range(8):b+=1if c[i]>0 else 0
print(max(b,1), b+c[8])
import sys
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra


def get_path(graph, s, t):
    if s == t:
        return [], [], 0
    else:
        path_cost, town = dijkstra(adjacency_matrix, return_predecessors=True, indices=s)
        path, costs, pre_cost = get_path(graph, s, town[t])
        path.append(town[t])
        costs.append(path_cost[t] - pre_cost)
        return path, costs, path_cost[t]


n, m, l = map(int, input().split())
abc = []
for mi in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    abc.append([a, b, c])
    abc.append([b, a, c])
q = int(input())
st = []
for i in range(q):
    s, t = map(int, input().split())
    st.append([s,t])


if m == 0:
    print(-1)
    sys.exit()

a, b, c = np.array(abc).T
adjacency_matrix = csr_matrix((c, (a,b)), (n, n))

for element in st:
    start, end = element[0]-1, element[1]-1
    _, costs, _ = get_path(adjacency_matrix, start, end)

    count = 0
    tmp_fuel = l
    for cost in costs:
        if tmp_fuel < cost:
            tmp_fuel = l
            count += 1
        tmp_fuel -= cost
    print(count)

### FIXED CODE ###

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

n, m, l = map(int, input().split())
abc = []
for _ in range(m):
    abc.append(map(int, input().split()))
q = int(input())
st = []
for _ in range(q):
    st.append(map(int, input().split()))

adjacency_matrix = np.zeros((n, n))
for a, b, c in abc:
    adjacency_matrix[a-1, b-1] = c
    adjacency_matrix[b-1, a-1] = c

shotest = dijkstra(adjacency_matrix)
fuel_once = np.where(shotest <= l, 1, 0)
fuel_times = dijkstra(fuel_once-np.eye(n))

for s, t in st:
    ans = fuel_times[s-1][t-1]
    if np.isinf(ans):
        print(-1)
    else:
        print(int(ans) - 1)
import numpy as np
N,W = map(int,input().split())
w,v = [],[]
for i in range(N):
    a,b = map(int,input().split())
    w += [a]
    v += [b]
dp = np.zeros(W+1,dtype = int)
for i in range(N):
    dp[w[i]:] = np.maximum(dp[:-w[i]]+v[i],dp[w[i]:])
print(dp[-1])

### FIXED CODE ###

import numpy as np
N,W=map(int,input().split())
dp=np.ones(10**5+1, dtype='int64')
dp[0]=0
dp[1:]=dp[1:]*(10**9+1)
for i in range(N):
    wi,vi=map(int,input().split())
    dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))
n = input()
count = 0
for i in xrange(n):
    x = input()
    if x == 2: count += 1
    elif x % 2 != 0:
        for j in xrange(3,x*0.5+1,2):
            if x % j == 0: break
        else: count += 1
print count

### FIXED CODE ###

import math
def prime(x):
    if x == 2: return True
    elif x % 2 == 0: return False
    else:
        for j in xrange(3,int(math.sqrt(x))+1,2):
            if x % j == 0: return False
        else:
            return True 
n = input()
count = 0
for i in xrange(n):
    if prime(input()): count += 1
print count
n,w = map(int, input().split())

if n % 2 == 0 or w % 2 == 0:
    ans = int((n * w) / 2.)

else : ans = int((n * w) / 2.) + 1

print(ans)

### FIXED CODE ###

n, w = map(int, input().split())


if n == 1 or w == 1: 
    ans = 1
elif n % 2 == 0 or w % 2 == 0:
    ans = int((n * w) / 2.)

else:
    ans = int((n * w) / 2.) + 1

print(ans)
N = input()
a = list(map(int, input().split()))

import sys

while True:
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i]/2
        else:
            print(t)
            sys.exit()
    t += 1


### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)
r, g, b, n = map(int, input().split())

ans = 0

for x in range(n+1):
    for y in range(n+1):
        if r*x + g*y >n:
            break
        for z in range(n+1):
            w = r*x + g*y + b*z
            if w>n:
                break
            if w == n:
                ans+=1
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())

ans = n - k +1
print(ans)
s=input()
if(s=="Rainy"):
print("Sunny")
elif(s=="Sunny"):
print("Cloudy")
else:
print("Rainy")

### FIXED CODE ###

s=input()
if(s=="Rainy"):
    print("Sunny")
elif(s=="Sunny"):
    print("Cloudy")
else:
    print("Rainy")
h, w = map(int, input().split())
mapping = [0]*h
for i in range(h):
  mapping[i] = [int(x)%2 for x in input().split()]

ans = []
side = [0]*h
key = 0
for i in range(h):
  k = 0
  for j in range(w-1):
    if mapping[i][j]:
      if k == 0:
        k = 1
        ans.append([i+1, j+1, i+1, j+2])
      else:
        k = 0
    else:
      if k == 1:
        ans.append([i+1, j+1, i+1, j+2])
      else:
        continue
    if j == w-2 and k == 1:
      side[i] = 1
      key += 1
k = 0
key //= 2
for i in range(h-1):
  if mapping[i][j]:
    if k == 0:
      k = 1
      ans.append([i+1, w, i+2, w])
    else:
      k = 0
  else:
    if k == 1:
      ans.append([i+1, w, i+2, w])
      key -= 1
    else:
      continue 
  if not key:
    break

print(len(ans))
for i in range(len(ans)):
  print(*ans[i])

### FIXED CODE ###

h, w = map(int, input().split())
a = [0]*h
for i in range(h):
  a[i] = [int(x)%2 for x in input().split()]

ans = 0
ans_list = []
key = 0
for i in range(h):
  if i%2 == 0:
    for j in range(w):
      p = a[i][j]
      if key == 0:
        if p == 0:
          pass
        else:
          key = 1
      else:
        if p == 0:
          key = 1
          ans += 1
          if j == 0:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j, i+1, j+1])
        else:
          key = 0
          ans += 1
          if j == 0:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j, i+1, j+1])
        
      
  else:
    for j in range(w-1, -1, -1):
      p = a[i][j]
      if key == 0:
        if p == 0:
          pass
        else:
          key = 1
      else:
        if p == 0:
          key = 1
          ans += 1
          if j == w-1:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j+2, i+1, j+1])
        else:
          key = 0
          ans += 1
          if j == w-1:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j+2, i+1, j+1])

print(ans)
for i in range(ans):
  print(*ans_list[i])
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")
N, M = map(int,input().split())
A = list(map(int,input().split()))
B = 0
C = 0

for i in range(list(A)):
  c += A[i]
  
for i in range(list(A)):
  if A[i] >= 1/(4*M):
    B += 1

if B >= M:
  print('Yes')
else:
  print('No')
    

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
B = 0
C = 0

for i in range(len(A)):
  C += A[i]
  
for i in range(len(A)):
  if A[i] >= C/(4*M):
    B += 1

if B >= M:
  print('Yes')
else:
  print('No')
H,W=[int(i) for i in input().split()]
s=[input() for i in range(H)]

def search(h,w):
        if s[h][w]=='#':
                return '#'
        count=0
        for i in range(-1,2):
                for j in range(-1,2):
                        if (i!=0 or j!=0) and 0<=h+i and h+i<H and 0<=w+j and w+j<W:                                if s[h+i][w+j]=='#':
                                        count+=1
        return count

for h in range(H):
        for w in range(W):
                print(search(h,w),end='')
        print()

### FIXED CODE ###

H,W=[int(i) for i in input().split()]
s=[input() for i in range(H)]

def search(h,w):
        if s[h][w]=='#':
                return '#'
        count=0
        for i in range(-1,2):
                for j in range(-1,2):
                        if 0<=h+i and h+i<H and 0<=w+j and w+j<W:
                                if i!=0 or j!=0:
                                        if s[h+i][w+j]=='#':
                                                count+=1
        return count

for h in range(H):
        for w in range(W):
                print(search(h,w),end='')
        print()
from collections import deque


k = int(input())
d = deque([1,2,3,4,5,6,7,8,9])

for i in range(k):
    a = d.popleft()
    if a % 10 != 0:
        d.append(a*10 + a % 10 - 1)
    d.append(a*10 + a % 10)
    if a % 10 != 9:
        d.append(i*10 + i % 10 + 1)

print(a)




### FIXED CODE ###

x,y,z = map(int, input().split())

print(z, x, y)
h, w = map(int, input().split())
s = [input() for i in range(n)]
for i in range(h):
  for j in range(w):
    if s[i][j] = "#":
      d = set()
      if i>0:
        d.add(s[i-1][j])
      if i<h-1:
        d.add(s[i+1][j])
      if j>0:
        d.add(s[i][j-1])
      if j<w-1:
        d.add(s[i][j+1])
      if "#" not in d:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

h, w = map(int, input().split())
s = [input() for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      d = set()
      if i>0:
        d.add(s[i-1][j])
      if i<h-1:
        d.add(s[i+1][j])
      if j>0:
        d.add(s[i][j-1])
      if j<w-1:
        d.add(s[i][j+1])
      if "#" not in d:
        print("No")
        exit()
print("Yes")
N = int(input())
H = list(map(int, input().split()))
cnt = 1
for i in range(1, N):
    if i == 1:
        if H[0] <= H[1]:
            cnt += 1
    else:
        elif max(H[:i-1]) <= H[i]:
            cnt += 1
print(cnt)

### FIXED CODE ###

A,B=map(int,input().split())
s=0
if A > B:
    s=A+(A-1)
elif A < B:
    s=B+(B-1)
else:
    s=A+B
print(s)
import sympy

n = int(input())
res = sum([i * len(sympy.divisors(i)) for i in range(1, n+1)])
print(res)

### FIXED CODE ###

n = int(input())
board = [1] * (n+1)

def divisor_num(n, board):
    for i in range(2, n+1):
        j = 1
        while i*j <= n:
            board[i*j] += 1
            j += 1

divisor_num(n, board)
res = sum([i * board[i] for i in range(1, n+1)])
print(res)
A=list(input().split())

if A[0]==A[1] and A[2]==A[3]:
    print("Yes")
elif A[0]==A[2] and A[1]==A[3]:
    print("Yes")
elif A[0]==A[3] and A[1]==A[2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A=list(map(str,input()))

if A[0]==A[1] and A[0]==A[2] and A[0]==A[3]:
    print("No")
elif A[0]==A[1] and A[2]==A[3]:
    print("Yes")
elif A[0]==A[2] and A[1]==A[3]:
    print("Yes")
elif A[0]==A[3] and A[1]==A[2]:
    print("Yes")
else:
    print("No")