Harryxun/stf_run huggingface dataset:
h, w = map(int,input().split())
pic = []

kabe_up_down = []
for i in range(w):
    kabe.append('.')

for i in range(h):
    onelist = ['.']
    inp = list(str(input()))
    for i in range(len(inp)):
        onelist.append(inp[i])
    onelist.append('.')
    pic.append(onelist)
    
flag = 1
a = 'a'
for i in range(1,h+1):
    for j in range(1,w+1):
        here = pic[i][j]
        if here =='#' and pic[i+1][j] == '#':
            pic[i][j] = a
            pic[i+1][j] = a
        elif here =='#' and pic[i][j+1] == '#':
            pic[i][j] = a
            pic[i][j+1] = a
            
for i in range(h+1):
    for j in range(w+1):
        if pic[i][j] == #:
        flag = 0
        break
        
if flag == 0:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

h, w = map(int,input().split())
pic = []

kabe_up_down = []
for i in range(w+2):
    kabe_up_down.append('.')
pic.append(kabe_up_down)

for i in range(h):
    onelist = ['.']
    inp = list(str(input()))
    for mm in range(len(inp)):
        onelist.append(inp[mm])
    onelist.append('.')
    pic.append(onelist)
    
pic.append(kabe_up_down)    


flag = 1
a = 'a'
for i in range(1,h+1):
    for j in range(1,w+1):
        here = pic[i][j]
        if here =='#' and pic[i+1][j] == '#':
            pic[i][j] = a
            pic[i+1][j] = a
        elif here =='#' and pic[i][j+1] == '#':
            pic[i][j] = a
            pic[i][j+1] = a
        elif here =='#' and pic[i-1][j] == '#':
            pic[i][j] = a
            pic[i-1][j] = a
        elif here =='#' and pic[i][j+1] == '#':
            pic[i][j] = a
            pic[i][j+1] = a    
            
for i in range(1,h+1):
    for j in range(1,w+1):
        here = pic[i][j]
        if here == '#' and pic[i+1][j] == 'a':
            pic[i][j] = a
            pic[i+1][j] = a
        elif here =='#' and pic[i][j+1] == 'a':
            pic[i][j] = a
            pic[i][j+1] = a
        elif here =='#' and pic[i-1][j] == 'a':
            pic[i][j] = a
            pic[i-1][j] = a
        elif here =='#' and pic[i][j+1] == 'a':
            pic[i][j] = a
            pic[i][j+1] = a    
        
for i in range(1,h+1):
    for j in range(1,w+1):
        here = pic[i][j]
        if here == a and pic[i+1][j] == '#':
            pic[i][j] = a
            pic[i+1][j] = a
        elif here =='a' and pic[i][j+1] == '#':
            pic[i][j] = a
            pic[i][j+1] = a
        elif here =='a' and pic[i-1][j] == '#':
            pic[i][j] = a
            pic[i-1][j] = a
        elif here =='a' and pic[i][j+1] == '#':
            pic[i][j] = a
            pic[i][j+1] = a            
            
for i in range(1,h+1):
    for j in range(1,w+1):
        if pic[i][j] == '#':
            flag = 0
            

if flag == 0:
    print('No')
else:
    print('Yes')
n=input()
array=list(map(int,input()))
array1=array.sort()
import itertools
list1=itertools.combinations(array1,3)
ans=0
for n in range(len(list1)):
  if list[n][0]!=list[n][1] and list[n][1]!=list[n][2]:
    if list[n][0]+list[n][1]>list[n][2]:
      ans=ans+1
print(ans)

### FIXED CODE ###

import itertools
n = int(input())
data = list(map(int, input().split()))
data1=sorted(data)
a = list(itertools.combinations(data1,3))
ans=0
for m in range(len(a)):
  if a[m][0]!=a[m][1] and a[m][1]!=a[m][2]:
    if a[m][0]+a[m][1]>a[m][2]:
      ans=ans+1
print(ans)
n, k = [int(_) for _ in input().split()]
ary = [int(input()) for _ in range(n)]


def search_v(p):
    v = 0
    w = 0
    tmp_k = 1
    ind = 0

    while True:

        if tmp_k > k:
            return v
        if ind == n:
            return n

        tmp = ary[ind]
        if w + tmp <= p:
            w += tmp
            v += 1
            ind += 1
        else:
            w = 0
            tmp_k += 1


max_p = n * k
ps = range(1, max_p + 1)
left = 0
right = max_p

while left + 1 < right:
    mid = (left + right) // 2
    v = search_v(ps[mid])

    if v >= n:
        right = mid
    else:
        left = mid

print(ps[right])



### FIXED CODE ###

n, k = [int(_) for _ in input().split()]
ary = [int(input()) for _ in range(n)]


def search_v(p):
    v = 0
    w = 0
    tmp_k = 1
    ind = 0

    while True:

        if tmp_k > k:
            return v
        if ind == n:
            return n

        tmp = ary[ind]
        if w + tmp <= p:
            w += tmp
            v += 1
            ind += 1
        else:
            w = 0
            tmp_k += 1


max_p = n * 10000
ps = range(max_p + 1)
left = 0
right = max_p

while left + 1 < right:
    mid = (left + right) // 2
    v = search_v(ps[mid])

    if v >= n:
        right = mid
    else:
        left = mid

print(ps[right])
a,b=map(int,input().split(' '))
print(0-(-a//b))

### FIXED CODE ###

print(3*int(input())**2)
s,t,count=input(),input(),0

for i in range(len(s)):
  if s[i]!=t[i]:
    count++
print(count)


### FIXED CODE ###

s,t,count=input(),input(),0

for i in range(len(s)):
  if s[i]!=t[i]:
    count+=1
print(count)
def comb(n, r):
  if r > n - r:
    r = n - r
  if r == 0:
    return 1
  return (n - r + 1) * comb(n, r - 1) // r

N, K = list(map(int, input().split()))
for i in range(K):
  print(comb(N - K + 1, i  + 1) * comb(K - 1, i) % 1000000007)

### FIXED CODE ###

def comb(n, r):
  if n < 0 or r < 0:
    raise ValueError
  r = min(r, n - r)
  if n == 0 or r == 0:
    return 1
  return (n - r + 1) * comb(n, r - 1) // r

N, K = list(map(int, input().split()))
for i in range(K):
  if N - K + 1 < i + 1:
    print('0')
    continue
  print(comb(N - K + 1, i + 1) * comb(K - 1, i) % (10 ** 9 + 7))
N, K = map(int, input().split())
X = list(map(int, input().split()))

minus = [0]
plus = [0]
for x in X:
    if x < 0:
        minus.append(abs(x))
    elif x == 0:
        K -= 1
    else:
        plus.append(x)

#負の数の方を絶対値に基づき並べなおす
minus.sort()

ans = []
for i in range(max(0, K - len(plus), min(len(minus), K))):
    ans.append(min(minus[i] * 2 + plus[K - i], minus[i] + plus[K - i] * 2))

if len(X) == 1:
    ans.append(X[0])

print(min(ans))

### FIXED CODE ###

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

minus = [0]
plus = [0]
for x in X:
    if x < 0:
        minus.append(abs(x))
    elif x == 0:
        K -= 1
    else:
        plus.append(x)

#負の数の方を絶対値に基づき並べなおす
minus.sort()

a = len(minus) - 1
b = len(plus) - 1

ans = []
for i in range(max(0, K - b), min(a, K) + 1):
    ans.append(min(minus[i] * 2 + plus[K - i], minus[i] + plus[K - i] * 2))

if len(X) == 1:
    ans.append(X[0])

print(min(ans))
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0]*m for _ in range(n)]
if s[0]==t[0]:
    dp[0][0]=1
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j-1]+1
        else:
            if i>0:
                dp[i][j]=max(dp[i][j],dp[i-1][j])
            if j>0:
                dp[i][j]=max(dp[i][j],dp[i][j-1])
leng=dp[n-1][m-1]
i,j=n-1,m-1
ans=""
while leng>0:
    if s[i]==t[j]:
        ans+=s[i]
        i-=1
        j-=1
        leng-=1
    else:
        if dp[i-1][j]==dp[i][j]:
            i-=1
        elif dp[i][j-1]==dp[i][j]:
            j-=1
print(ans[::-1])

### FIXED CODE ###

s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1,m+1):
        if s[i-1]==t[j-1]:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j-1]+1
        else:
            if i>0:
                dp[i][j]=max(dp[i][j],dp[i-1][j])
            if j>0:
                dp[i][j]=max(dp[i][j],dp[i][j-1])
leng=dp[n][m]
i,j=n,m
ans=""
while leng>0:
    if s[i-1]==t[j-1]:
        ans+=s[i-1]
        i-=1
        j-=1
        leng-=1
    else:
        if dp[i-1][j]==dp[i][j]:
            i-=1
        elif dp[i][j-1]==dp[i][j]:
            j-=1
print(ans[::-1])
import numpy as np
N, K = map(int, input().split())
A = np.array(map(int, input().split()))


for i in range(K):
    cum_sum = np.array([0]*N)
    for j in range(N):
        left = max(0, j - A[j])
        right = min(N-1, j+A[j])
        cum_sum[left] += 1
        if right + 1 < N:
            cum_sum[right+1] -= 1
    A[0] = cum_sum[0]
    for j in range(N-1):
        cum_sum[j+1] += cum_sum[j]
        A[j+1] = cum_sum[j+1]

    if A[0] == N and A[N-1] == N:
        break
    
        
for i in range(N):
    print(A[i], " ", end = "")
print()


### FIXED CODE ###

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


for i in range(min(K, 42)):
    cum_sum = [0]*N
    for j in range(N):
        left = max(0, j - A[j])
        right = min(N-1, j+A[j])
        cum_sum[left] += 1
        if right + 1 < N:
            cum_sum[right+1] -= 1
    A[0] = cum_sum[0]
    for j in range(N-1):
        cum_sum[j+1] += cum_sum[j]
        A[j+1] = cum_sum[j+1]
    
        
for i in range(N):
    print(A[i], " ", end = "")
print()
i=open(0).read().split()[1:]
print(["Three","Four"][if "Y" in i])

### FIXED CODE ###

i=open(0).read().split()[1:]
print(["Three","Four"]["Y" in i])
import math
def min_cost(arr):
    dp = [math.inf for _ in range(len(arr))]
    dp[0] = 0
    for i in range(len(arr)+1):
        for j in range(i+1,i+3):
            if   j < len(arr):
                dp[j] =  min(dp[j],dp[i] + abs(arr[i]-arr[j]))
        
    return dp[len(arr)-1]

n = input()
arr = list(map(int,input().split()))
print(min_cost(arr))

### FIXED CODE ###

import math
def min_cost(arr):
    n = len(arr)
    dp = [0 for _ in range(n)]
    dp[1] = abs(arr[1]- arr[0])
    for i in range(2,n):
        dp[i] =  min(dp[i-1] + abs(arr[i] - arr[i-1]),dp[i -2 ] + abs(arr[i]-arr[i-2]))
        
    return dp[n-1]

n = input()
arr = list(map(int,input().split()))
print(min_cost(arr))
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
na = []
c = 0
for booka in a:
  c += booka
  na.append(c)
nb = []
d = 0
for bookb in b:
  d += bookb
  nb.append(d)
maxa = 0
for i in range(n):
  for j in range(maxa-i,m):
    if na[i] + nb[j] <= k:
      maxa = max(maxa,i+j+2)
print(maxa)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
na,nb = [0],[0]
for i in range(n):
  na.append(na[i]+a[i])
for j in range(m):
  nb.append(nb[j]+b[j])
ans = 0
l = m
for i in range(n+1):
  if na[i] > k:
    break
  while nb[l] > k - na[i]:
    l -= 1
  ans = max(ans,i+l)
print(ans)
import sys
sys.setrecursionlimit(pow(10,6))
class UnionFind():
    def __init__(self,n):
        self.root = [-1]*n
        self.rank = [1]*n
    def find(self,x):
        if self.root[x]==-1:
            return x
        else:
            return self.find(self.root[x])
    def union(self,x,y):
        root_x,root_y = self.find(x),self.find(y)
        if self.rank[root_x]<self.rank[root_y]:
            root_x,root_y = root_y,root_x
        self.rank[root_x] += self.rank[root_y]
        self.root[root_y] = root_x

N,M = map(int,input().split())
P = list(map(lambda x:int(x)-1,input().split()))
T = UnionFind(N)
for i in range(M):
    x,y = map(lambda x:int(x)-1,input().split())
    T.union(x,y)
cnt = 0
for i in range(N):
    p = P[i]
    if T.find(i)==T.find(p):
        cnt+=1
print(cnt)

### FIXED CODE ###

import sys
sys.setrecursionlimit(pow(10,9))
class UnionFind():
    def __init__(self,n):
        self.root = [-1]*n
        self.rank = [1]*n
    def find(self,x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.find(self.root[x])
    def union(self,x,y):
        x,y = self.find(x),self.find(y)
        if x == y:return
        if self.rank[x]<self.rank[y]:
            x,y = y,x
        self.rank[x] += self.rank[y]
        self.root[y] = x

N,M = map(int,input().split())
P = list(map(lambda x:int(x)-1,input().split()))
T = UnionFind(N)
for i in range(M):
    x,y = map(lambda x:int(x)-1,input().split())
    T.union(x,y)
cnt = 0
for i in range(N):
    p = P[i]
    if T.find(i)==T.find(p):
        cnt+=1
print(cnt)
n, q = map(int, input().split())
s = input()
x = []

for i in range(q):
    s1, e1 = [int(i) for i in input().split()]
    x.append(s[s1-1:e1])

for i in x:
    print(i.count("AC"))

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
x = [0]*(n+1)

for i in range(n):
    x[i+1] = x[i] + (1 if s[i:i+2] == "AC" else 0)

for i in range(q):
    l, r = map(int, input().split())
    print(x[r-1] - x[l-1])
K = int(input())
A, B = map(int, input().split())

for i in range(A, B):
  if i % K == 0:
    print('OK')
    sys.exit()
print('NG')

### FIXED CODE ###

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

for i in range(A, B+1):
  if i % K == 0:
    print('OK')
    sys.exit()
print('NG')
n = int(input())
As = list(map(int, input().split()))
from math import gcd
# 左からの累積GCDと
g = As[0]
left = []
for a in As:
    g = gcd(g, a)
    left.append(g)
# 右からの累積GCD
As_r = As[::-1]
g_r = As_r[0]
right = []    
for a in As_r:
    g_r = gcd(g_r, a)
    right.append(g_r)
    
l = left
r = right[::-1]
ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans, r[1])
    elif i == n-1:
        ans = max(ans, l[n-2])
    else:     
        g = gcd(l[i-1],r[i+1])
        ans = max(ans, g)
print(ans)

### FIXED CODE ###

N  = int(input())
As = [int(i) for i in input().split()]

# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

# 最大公約数
def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

## 高々3種類調べれば良い

if N > 2:
    devs = make_divisors(gcd(As[0],As[1]))
    devs.extend(make_divisors(gcd(As[1],As[2])))
    devs.extend(make_divisors(gcd(As[2],As[0])))
    devs = list(set(devs))
    cnt = 1
    for dev in sorted(devs)[::-1]:
        a = sum([a%dev==0 for a in As])
        if N - a == 0 or N - a == 1:
            print(dev)
            break
else:
    print(max(As))
s=input()
if(s-2019/4/30 >0:
   print("TBD")
else:
   print("Heisei")

### FIXED CODE ###

s=input()
if(s>"2019/04/30"):
   print("TBD")
else:
   print("Heisei")
n,p = map(int, input().split())
s = input()

ans = 0
p0 = 0
dp = [0] * p
for i in s[::-1]:
    i = int(i)
    p0 = p0*10 % p
    dp[p0 + i] += 1
    ans += dp[p0]

print(ans)

### FIXED CODE ###

n,p = map(int, input().split())
s = input()

if(p==2)|(p==5):
    ans = 0
    for i in range(n):
        tmp = int(s[i])
        if(tmp%p == 0):
            ans += (i+1)

    print(ans)
    exit()

ans = 0
tmp = 0
rem = [0] * p
rem[0] = 1
for i in range(n):
    tmp = (tmp + int(s[-1 * (i+1)]) * pow(10, i, p)) % p
    ans += rem[tmp]
    rem[tmp] += 1

print(ans)
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


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

for i in range(N - 1):
	a, b = list(map(int, input().split()))

for i in range(Q):
	p, x = list(map(int, input().split()))



### FIXED CODE ###


a = int(input())
s = input()
if a >= 3200:
	print(s)
else:
	print("red")
N = int(input())
a = N[-1]

if a == 3:
  print('bon')
elif a == 0 or a == 1 or a == 6 or a == 8:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

N = int(input())
a = N%10
 
if a==3:
  print("bon")
elif a==0 or a==1 or a==6 or a==8:
  print("pon")
else:
  print("hon")
import bisect
n,m = map(int,input().split())

l1 = [[] for i in range(n)]
l2 = []

for i in range(m):
    p,y = map(int,input().split())
    l1[p-1].append(y)
    l2.append((p,y))

for p in range(n):
    l1[p].sort()

for i in range(m):
    p = l2[i][0]
    k = bisect.right(l1[p-1],l2[i][1])
    p = str(p)
    k = str(k)
    ans = "0"*(6-len(p))+p+"0"*(6-len(k))+k
    print(ans)


### FIXED CODE ###

s=input().split()
n=int(s[0])
m=int(s[1])
l=[[] for i in range(100000)]
d=[{} for i in range(100000)]
inp=[]
for i in range(m):
    s=input().split()
    p=int(s[0])
    y=int(s[1])
    inp.append((p,y))
    l[p-1].append(y)
for i in range(100000):
    l[i].sort()
for i in range(100000):
    cnt=1
    for j in l[i]:
        d[i][j]=cnt
        cnt+=1
for pa in inp:
    L=pa[0]
    R=d[L-1][pa[1]]
    L=str(L)
    R=str(R)
    for i in range(6-len(L)):
        print("0",end="")
    print(L,end="")
    for i in range(6-len(R)):
        print("0",end="")
    print(R)
n = int(input())
INF = 10**9
P = []
for i in range(n):
    p = map(int, input().split())
    P.append()
m = [[0]*n for i in range(n)]

for l in range(2, n + 1):
    for i in range(n - l + 1):
        j = i + l - 1
        m[i][j] = INF
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + P[i - 1][0] * P[k][1] * P[j][1])

print(m[0][n - 1])

### FIXED CODE ###

n = int(input())
INF = 10**9
P = [list(map(int, input().split())) for i in range(n)]
m = [[0]*n for i in range(n)]

for l in range(2, n + 1):
    for i in range(n - l + 1):
        j = i + l - 1
        m[i][j] = INF
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + P[i][0] * P[k][1] * P[j][1])

print(m[0][n - 1])
A,P = map(int,input().split())     
    A = int(A)
    P = int(P)
     
    P = (A*3) + P
    ans = P / 2
     
    ans = round(ans)
     
    print(ans)
     

### FIXED CODE ###

A,P = map(int,input().split())
ans = 0

A = int(A)
P = int(P)

P = (A*3) + P
ans = P // 2

print(ans)
from scipy.special import comb
# a = comb(n, r)
#a = comb(n, r, exact=True)
lis=list(map(int,input().split()))
mod=(10**9)+7
for i in range(lis[1]):
    ans=comb(lis[0]-lis[1]+1,i+1,exact=True)%mod
    ans=ans*comb(lis[1]-1,i,exact=True)%mod
    print(ans)


### FIXED CODE ###

lis=list(map(int,input().split()))
mod=(10**9)+7
pascal=[]
#print(lis[0]-lis[1]+1,lis[1]-1)
rank=max(lis[0]-lis[1]+1,lis[1]+1)
for i in range(rank):
    pascal.append([])
    for j in range(i+2):
        if j==0 or j==i+1:
            pascal[i].append(1)
        else:
            pascal[i].append(pascal[i-1][j-1]+pascal[i-1][j])
#print(len(pascal[-1]))
for i in range(1,1+lis[1]):
    if i<=lis[0]-lis[1]+1:
        ans=pascal[lis[0]-lis[1]][i]*pascal[lis[1]-2][i-1]%mod
    else:
        ans=0
    print(ans)
n = int(input())
_ = list(map(int, input()))
a = []
for i in range(1,n+1):
  a.append(_[i-1], i)
  
ans = []
a_sort = (sorted(a, key=lambda x: x[0]))
for i in range(n):
  ans.append(a_sort[i][1])
  
print(' '.join(list(map(str, ans))))

### FIXED CODE ###

n = int(input())
_ = list(map(int, input().split()))
a = []
for i in range(1,n+1):
  a.append([_[i-1], i])
  
ans = []
a_sort = (sorted(a, key=lambda x: x[0]))
for i in range(n):
  ans.append(a_sort[i][1])
  
print(' '.join(list(map(str, ans))))
while True:
    n = int(raw_input())
    try:
        ls = map(int,raw_input().split())
        mi = min(ls)
        ma = max(ls)
        su = sum(ls)
        print "%d %d %d" %(mi,ma,su)
        
    except EOFError:
        break        

### FIXED CODE ###

n = int(raw_input())

ls = map(int,raw_input().split())
mi = min(ls)
ma = max(ls)
su = sum(ls)
print "%d %d %d" % (mi,ma,su)
A,B,T=map(input(),split())
a=int(T/A+0.5)
print(a*B)

### FIXED CODE ###

A,B,T=map(int,input().split())
count=0
while T>=A:
	T=T-A
	count+=1
print(count*B)
import sys
def maxcost(li,n,i,strt,dp):
    if i==(n-1):
        return li[i][strt]
    mx=-sys.maxsize
    for l in range(3):
        if l!=strt:
            if dp[i+1][l]==-1:
                cost=maxcost(li,n,i+1,l,dp)
                dp[i+1][l]=cost
            else:
                cost=dp[i+1][l]
            mx=max(mx,cost+li[i][strt])
    return mx


n=int(input())
li=[]
for i in range(n):
    temp=[int(x) for x in input().split()]
    li.append(temp)
dp=[[-1 for j in range(3)] for i in range(n)]
print(max(maxcost(li,n,0,0,dp),maxcost(li,n,0,1,dp),maxcost(li,n,0,2,dp)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def maxcost(li,n,i,strt,dp):
    if i==(n-1):
        return li[i][strt]
    mx=-sys.maxsize
    for l in range(3):
        if l!=strt:
            if dp[i+1][l]==-1:
                cost=maxcost(li,n,i+1,l,dp)
                dp[i+1][l]=cost
            else:
                cost=dp[i+1][l]
            mx=max(mx,cost+li[i][strt])
    return mx


n=int(input())
li=[]
for i in range(n):
    temp=[int(x) for x in input().split()]
    li.append(temp)
dp=[[-1 for j in range(3)] for i in range(n)]
print(max(maxcost(li,n,0,0,dp),maxcost(li,n,0,1,dp),maxcost(li,n,0,2,dp)))
import math
N=int(input())
m=N+1
for j in range(2,math.sqrt(N)):
    if N%j==0:
        a=j
        b=N//j
        if a>b:
            break
        else:
            m=min(m,(a+b))

print(m-2)


### FIXED CODE ###

import math
N=int(input())
m=N+1
for j in range(2,int(math.sqrt(N))+1):
    if N%j==0:
        a=j
        b=N//j
        if a>b:
            break
        else:
            m=min(m,(a+b))

print(m-2)
a,b,c,d,e,f=map(int,input().split())
if c=d,e=f:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S=input()
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")
N=int(raw_input())

A = [0 for i in range(N)]

for i in range(N):
    a=int(raw_input())
    A[a-1]=(a-1]+1)%2

print sum(A)

### FIXED CODE ###

N=int(raw_input())
A = []
for i in range(N):
    A.append(int(raw_input()))

A.sort()
prev=A[0]
count=1
all_count=0
for i in range(1,N):
    if prev==A[i]:
        count+=1
    else:
        prev=A[i]
        all_count+=count%2
        count=1
all_count+=count%2

print all_count
G1 = [1, 3, 5, 7, 8, 10, 12]
G2 = [4, 6, 9, 11]

x, y = map(int, input().strip().split(' '))

if x in G1 and y in G1or x in G2 and y in G2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

G1 = [1, 3, 5, 7, 8, 10, 12]
G2 = [4, 6, 9, 11]
 
x, y = map(int, input().strip().split(' '))
 
if x in G1 and y in G1 or x in G2 and y in G2:
    print("Yes")
else:
    print("No")
#import numpy as np
import time

N = int(input())
A = list(map(int, input().split()))
A.sort()#わるほう
remove_list = []

kouho = sorted([x for x in set(A) if A.count(x) == 1])
#maxA = 10**5

#target = kouho[:]
if kouho != []:
    maxA = kouho[-1]
    work=[0]*(maxA+1)

for i in range(len(A)):
    if kouho == []:
        break
    maxN = int(maxA/A[i])
    for n in range(1,maxN+1):
        buf = A[i]*n
        #remove_list.append(buf)
        work[buf]+=1
            #print(A[i]*n)

#target = kouho[:]
#kouho = list(set(kouho) - set(remove_list))

if kouho == []:
    print(0)
else:
    sm=0
    for s in A:
        if work[s]==1: sm+=1
    print(sm)

#print(len(kouho))

### FIXED CODE ###

#import numpy as np

N = int(input())
A = list(map(int, input().split()))
A.sort()#わるほう

#kouho = sorted([x for x in set(A) if A.count(x) == 1])
#maxA = 10**5

#target = kouho[:]
maxA = A[-1]
work=[0]*(A[-1]+1)

for i in range(len(A)):
    if work[A[i]]<=1:
        maxN = int(maxA/A[i])
        for n in range(1,maxN+1):
            buf = A[i]*n
            #remove_list.append(buf)
            work[buf]+=1
                #print(A[i]*n)

#target = kouho[:]
#kouho = list(set(kouho) - set(remove_list))

sm=0
for s in A:
    if work[s]==1: sm+=1
print(sm)

#print(len(kouho))
s = input()
while True:
	S = s
	if len(S) < 5:
		print('NO')
		break
	if S == 'dream' or S == 'erase':
		print('YES')
		break
	else:
		if S[0] == 'd':
			if S[7] == 'a':
				T ='dream'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'dreamer'
				if S[:7] == T:
					S = S[7:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		if S[0] == 'e':
			if len(S) >= 6 and S[5] == 'r':
				T = 'eraser'
				if S[:6] == T:
					S = S[6:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
			else:
				T = 'erase'
				if S[:5] == T:
					S = S[5:]
					T = ""
					if S == "":
						print('YES')
						break
					s = S
				else:
					print('NO')
					break
		else:
            print('NO')
            break

### FIXED CODE ###

S=input()
 
S=S.replace('eraser','')
S=S.replace('erase','')
S=S.replace('dreamer','')
S=S.replace('dream','')
 
if S=='':
    print('YES')
else:
    print('NO')