Harryxun/stf_run huggingface dataset:
def solve_commentary():
    N, K = map(int, input().split())
    R = N - K  # 赤玉の数
    MOD = 10 ** 9 + 7
    for i in range(1, K + 1):
        print((combinations_count(N - K + 1, i) * combinations_count(K - 1, i - 1)) % (MOD))
        pass
    pass


def combinations_count(n, r):
    import math
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def ppprint(itr_obj):
    for ite in itr_obj:
        print(ite)


if __name__ == '__main__':
    # solve()
    solve_commentary()


### FIXED CODE ###


def solve_commentary():
    N, K = map(int, input().split())
    R = N - K  # 赤玉の数
    MOD = 10 ** 9 + 7
    for i in range(1, K + 1):
        if N - K + 1 >= i:
            print((combinations_count(N - K + 1, i) * combinations_count(K - 1, i - 1)) % (MOD))
        else:
            print(0)
        pass
    pass


def combinations_count(n, r):
    import math
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def ppprint(itr_obj):
    for ite in itr_obj:
        print(ite)


if __name__ == '__main__':
    # solve()
    solve_commentary()
A=str(input())
A=list(A)
B=[]
for i in A:
  if i=="0":
    B.append("0")
  elif i=="1":
    B.append("1")
  elif i=="B":
    B.pop(-1)
print(''.join(B))

### FIXED CODE ###

A=str(input())
A=list(A)
B=[]
for i in A:
  if i=="0":
    B.append("0")
  elif i=="1":
    B.append("1")
  elif i=="B":
    B=B[:-1]
print(''.join(B))
def main():
    n, k = map(int, input().split(' '))
    result = [n//i*max(0,i-k) + max(0, n%i-k+1) for i in range(1, n+1)]
    if k == 0:
        result -= n
    print(result)
main()

### FIXED CODE ###

n, k = map(int, input().split(' '))
result = 0
for i in range(1, n+1):
    p = n//i
    result += p*max(0,i-k)
    result += max(0, n%i-k+1)
    if k == 0:
        result -= 1
print(result)
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n = onem()

a = l()
a.sort()
a = cl.deque(a)
aa = []
co = 0
while True:
    if len(a) == 3:
        if a[1] >= 0:
            z = a.pop()
            zz = a.popleft()
            a.appendleft(zz - z)
            aa.append([zz,z])
        else:
            z = a.pop()
            zz = a.popleft()
            a.append(z - zz)
            aa.append([z,zz])
    elif len(a) == 2:
        aa.append([max(a),min(a)])
        bs.insort(a,max(a),min(a))
        break
    elif len(a) == 1:
        break
    if co % 2 == 0:
        z = a.pop()
        zz = a.popleft()
        a.append(z - zz)
        aa.append([z,zz])
        co += 1
    else:
        z = a.pop()
        zz = a.popleft()
        a.appendleft(zz - z)
        aa.append([zz,z])
        co += 1

print(a[0])
for i in range(n-1):
    print(jo(aa[i]))



### FIXED CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

n = onem()

a = l()
a.sort()
a = cl.deque(a)
aa = []
co = 0
up = a.pop()
do = a.popleft()

for i in range(len(a)):
    if a[i] >= 0:
        aa.append([do,a[i]])
        do -= a[i]
    else:
        aa.append([up,a[i]])
        up -= a[i]    
aa.append([up,do])
print(up-do)
for i in range(n-1):
    print(jo(aa[i]))
input_ = input().split()
N, K, X, Y = input_

acc = 0

if N > K:
    acc = int(K) * int(X) + int(N - K) * int(Y)
else:
    acc = int(N) * int(X)

print(acc)

### FIXED CODE ###

input_ = [input() for i in range(4)]

N, K, X, Y = input_

acc = 0

if int(N) > int(K):
    acc = (int(K) * int(X)) + ((int(N) - int(K)) * int(Y))    
else:
    acc = int(N) * int(X)

print(acc)
N = int(input())
S = []
for i in range(N):
  s.append(input())

M = int(input())
T = []
for i in range(M):
  t.append(input())

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  S.append(input())

M = int(input())
T = []
for i in range(M):
  T.append(input())

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)
N,Y = map(int,input().split(" "))

t = int(Y/10000)
end=False
for x in range(1,t+1):
    for y in range(1,20001):
        for z in range(1,20001):
            ans = x*10000+y*5000+z*1000
			if ans==Y and x+y+z==N:
                print(str(x)+" "+str(y)+" "+str(z))
                end=True
                break
        if end:
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")

### FIXED CODE ###

N,Y = map(int,input().split(" "))

t = int(Y/10000)
end=False
for x in range(0,t+1):
    for y in range(0,N+1):
        if x+y>N:
            break
        z = N-x-y
        num = x*10000+y*5000+z*1000
        if num==Y:
            print(str(x)+" "+str(y)+" "+str(z))
            end=True
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")
N,K = map(int,input().split())
 
 
def modpow(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res
 
def modinv(a,mod):
    return modpow(a,mod - 2,mod)
 
def cnk(a,b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1,MOD) % MOD
    return ret
 
 
for i in range(1,K+1):
    if i == 1:
        print(N-K+1)
    else:
        print(cnk(N-K+1,i)*cnk(K-1,i-1)%MOD)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N,K = map(int,input().split())
     
    def modpow(a,n,mod):
        res = 1
        while n > 0:
            if n & 1:
                res = res * a % mod
            a = a * a % mod
            n >>= 1
        return res
     
    def modinv(a,mod):
        return modpow(a,mod - 2,mod)
     
    def cnk(a,b):
        MOD = 10**9+7
        ret = 1
        for i in range(b):
            ret *= (a-i)
            ret %= MOD
            ret = ret * modinv(i+1,MOD) % MOD
        return ret
     
     
    for i in range(1,K+1):
        if i > N - K +1:
            print(0)
        elif i == 1:
            print(N-K+1)
        else:
            print(cnk(N-K+1,i)*cnk(K-1,i-1)%(10**9+7))
if __name__ == '__main__':
    main()
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")


N, T = map(int, f.readline().split())
ab = [list(map(int, f.readline().split())) for _ in range(N)]

Dp = [0 for _ in range(T+1)]

ab = sorted(ab, key = lambda x: x[0])

for i in range(N-1):
    for j in range(T-1,-1, -1):
        if j+ab[i][0] <= T-1:
            kari2 = Dp[j] + ab[i][1]
            if  Dp[j+ab[i][0]] < kari2:
                Dp[j+ab[i][0]] = kari2
        else:
            kari2 = Dp[j] +ab[i][1]
            if Dp[T] < kari2:
                Dp[T] = kari2
                
print(max(Dp))

### FIXED CODE ###

N, T = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

Dp = [0 for _ in range(T+1)]

ab = sorted(ab, key = lambda x: x[0])

for i in range(N):
    for j in range(T-1,-1, -1):
        if j+ab[i][0] <= T-1:
            kari2 = Dp[j] + ab[i][1]
            if  Dp[j+ab[i][0]] < kari2:
                Dp[j+ab[i][0]] = kari2
        else:
            kari2 = Dp[j] +ab[i][1]
            if Dp[T] < kari2:
                Dp[T] = kari2
                
print(max(Dp))
A,B={int(x) for x in input().split(" ")}

ans A+B

printf("error" if ans >=10 else ans)

### FIXED CODE ###

A, B = [int(x) for x in input().split(" ")]

ans = A + B

print("error" if ans >= 10 else ans)
import numpy as np
n=int(input())
s=[a for a in input()]
s=[a.replace('.','0') for a in s]
s=[a.replace('#','1') for a in s]
s=[int(a) for a in s]
p=[i for i, x in enumerate(s) if x == 1]
s = np.array(s)
cnt = np.sum(s)
for i in p:
    s[-1 * (n-i):] = 1 - s[-1 * (n-i):]
    _cnt = np.sum(s)
    if cnt > _cnt:
        cnt =_cnt
print(cnt)

### FIXED CODE ###

n=int(input())
s=input()
cnt =s.count('#')
l =[cnt]
for i in range(n):
    if s[n-i-1] == '#':
        cnt -= 1
        l.append(cnt)
    else:
        cnt+=1
        l.append(cnt)
print(min(l))
n = int(input())
a = list(map(int,input().split()))
c = 1

for i in range(len(a)):
    c = c * a[i]

if c > pow(10,18):
    print(-1)
else:
    print(c)

### FIXED CODE ###

a,b = map(int,input().split())
print(a * b)
import numpy as np

l = []

for _ in range(3):
    a = [int(x) for x in input().split()]
    l.append(a)

l = np.array(l)

def check(m):
    a = []
    for i in range(3):
        b,c = m[i,0] - m[i,1], m[i,1] - m[i,2]
        m.append((b,c))
    if a[0] != a[1] or a[1] != a[2]:
        return False
    else:
        return True

if check(l) and check(np.transpose(l)):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

l = []

for _ in range(3):
    l.append([int(x) for x in input().split()])

flag = True

v,h = [],[]

for i in range(3):
    a = l[i]
    b,c = a[0] - a[1], a[1] - a[2]
    v.append([b,c])

if v[0] != v[1] or v[1] != v[2]:
    flag = False

for i in range(3):
    a = [l[0][i], l[1][i], l[2][i]]
    b,c = a[0] - a[1], a[1] - a[2]
    h.append([b,c])

if h[0] != h[1] or h[1] != h[2]:
    flag = False

if flag:
    print('Yes')
else:
    print('No')
n=input()
for i in ('+','-'):
  for j in ('+','-'):
    for k in ('+','-'):
      sm=a[0]+i+a[1]+j+a[2]+k+a[3]
      if eval(sm)==7:
        print(sm+'=7')
        exit()

### FIXED CODE ###

a=input()
for i in ('+','-'):
  for j in ('+','-'):
    for k in ('+','-'):
      sm=a[0]+i+a[1]+j+a[2]+k+a[3]
      if eval(sm)==7:
        print(sm+'=7')
        exit()
class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n)]
        self.rank=[0 for _ in range(n)]

    def find(self,x):
        if self.parent[x]==x:
            return x
        else:
            rootx=self.find(self.parent[x])
            self.parent[x]=rootx
            return rootx

    def union(self,x,y):
        rootx=self.find(x)
        rooty=self.find(y)
        if self.rank[rootx]<self.rank[rooty]:
            self.parent[rootx]=rooty
        else:
            self.parent[rooty]=rootx
            if self.rank[rootx]==self.rank[rooty]:
                self.rank[rootx]+=1

n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
for x,y,z in xyz:
    x,y=x-1,y-1
    uf.union(x,y)

# print(uf.parent)
for i in range(n):
    uf.find(n)
print(len(set(uf.parent)))

### FIXED CODE ###

class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n)]
        self.rank=[0 for _ in range(n)]

    def find(self,x):
        if self.parent[x]==x:
            return x
        else:
            rootx=self.find(self.parent[x])
            self.parent[x]=rootx
            return rootx

    def union(self,x,y):
        rootx=self.find(x)
        rooty=self.find(y)
        if self.rank[rootx]<self.rank[rooty]:
            self.parent[rootx]=rooty
        else:
            self.parent[rooty]=rootx
            if self.rank[rootx]==self.rank[rooty]:
                self.rank[rootx]+=1

n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
for x,y,z in xyz:
    x,y=x-1,y-1
    uf.union(x,y)

# print(uf.parent)
for i in range(n):
    uf.find(i)
print(len(set(uf.parent)))
a = int(input())
b = int(input())

ans = a // (b * 2)

if ans <= 0:
    ans = 0

print(ans)


### FIXED CODE ###

a, b = map(int, input().split())
ans = a - (b * 2)

if ans <= 0:
    ans = 0

print(ans)
arr=[0,1,1,2]
n=4*(10**5)+100
for i in range(4,n):
    b=bin(i)[2:]
    k=b.count('1')
    arr.append(arr[i%k]+1)
    #print(b,arr[i])
n=int(input())
z=input()
l=z.count('1')
l1=l+1
l2=l-1
ans1=0
ans2=0
for i in range(n):
    if(z[i]=='1'):
        u=pow(2,n-1-i,l1)
        ans1=(ans1+u)%l1
        if l2!=0:
            ans2=(ans2+pow(2,n-1-i,l2))%l2
for i in range(n):
    if z[i]=='0':
        p=ans1+pow(2,n-1-i,l1)
        p%=l1
        print(1+arr[p])
    else:
        p=ans2-pow(2,n-1-i,l2)
        p%=l2
        print(1+arr[p])
       

### FIXED CODE ###

arr=[0,1,1,2]
n=4*(10**5)+100
for i in range(4,n):
    b=bin(i)[2:]
    k=b.count('1')
    arr.append(arr[i%k]+1)
    #print(b,arr[i])
n=int(input())
z=input()
l=z.count('1')
l1=l+1
l2=l-1
ans1=0
ans2=0
for i in range(n):
    if(z[i]=='1'):
        u=pow(2,n-1-i,l1)
        ans1=(ans1+u)%l1
        if l2>0:
            ans2=(ans2+pow(2,n-1-i,l2))%l2
for i in range(n):
    if z[i]=='0':
        p=ans1+pow(2,n-1-i,l1)
        p%=l1
        print(1+arr[p])
    else:
        if l2==0:
            print(0)
        else:
            p=ans2-pow(2,n-1-i,l2)
            p%=l2
            print(1+arr[p])
import numpy as np

in_num = list(map(int, input().split()))
in_num2 = list(map(int, input().split()))
n = in_num[0]
k = in_num[1]
a = np.asarray(in_num2)

if k == 0 :
    print(np.sum(a))
else:

    b = np.arange(k).reshape(k,1) + 1
    c = np.bitwise_xor(a,b)

    print(np.max(np.sum(c,axis=1)))

### FIXED CODE ###

import numpy as np

m = list(map(int, input().split()))
t = m[0]
x = m[1]
print(t/x)
H, N = map(int,input().split())
magic = []
for i in range(N):
    a,b = map(int,input().split())
    magic.append((a, b))
magic.sort(reverse=True)

INF = 1<<60

def solve():
    btab = [INF] * (H+1)
    btab[0] = 0
    for h in range(1, magic[0][0]+1):
        btab[h] = min([b for a, b in magic if a >= h])
    for h in range(1, H+1):
        cand = [btab[s] + btab[h-s] for s in range(1, h) if s <= h-s]
        if not cand:
            continue
        cost = min(cand)
        if cost < btab[h]:
            btab[h] = cost
    return btab[H]

print(solve())

### FIXED CODE ###

H, N = map(int,input().split())
magic = []
for i in range(N):
    a,b = map(int,input().split())
    magic.append((a, b))
magic.sort(reverse=True)
amax, _ = magic[0]

INF = 1<<60

def solve():
    btab = [INF] * (H+1)
    btab[0] = 0
    oneshot = min(amax, H)
    for h in range(1, oneshot+1):
        btab[h] = min([b for a, b in magic if a >= h])
    for h in range(2, H+1):
        for a, b in magic:
            c = b + btab[max(h-a, 0)]
            if c < btab[h]:
                btab[h] = c
    return btab[H]

print(solve())
def minimumCost(n, hights):
  if (n < 2):
    print "0"
  else:
    memo = []
    memo[0] = 0
    memo[1] = abs(hights[0] - hights[1])
    for i in range(2, n):
      memo[i] = min((hights[i] - hights[i - 1] + memo [i - 1]), (hights[i] - hights[i - 2] + memo [i - 2]))
    print memo[n-1]

### FIXED CODE ###

def printArray(arr):
  for i in range(0, len(arr)):
    print(arr[i])
    
def minimumCost(n, hights):  
  if (n < 2):
    print("0")
  else:
    memo = []
    memo.append(0)
    memo.append(abs(hights[0] - hights[1]))
    for i in range(2, n):
      memo.append(min(
        (abs(hights[i] - hights[i - 1]) + memo [i - 1]), 
        (abs(hights[i] - hights[i - 2]) + memo [i - 2])
      ))
    print(memo[n-1])
    
n = int(input())
hights = list(map(int,input().split()))
minimumCost(n, hights)
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
if n % 2 == 0:
    n -= 1
ans = []
left_range = n//2
right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

while True:
    left1 += 1
    right1 -= 1
    if left1 >= right1:
        break
    ans.append([left1, right1])

while True:
    left2 += 1
    right2 -= 1
    if left2 >= right2:
        break
    ans.append([left2, right2])
    
for i in range(m):
    print(*ans[i])    




### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
if n % 2 == 0:
    n -= 1
ans = []
left_range = n//2
right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

while True:
    if left1 >= right1:
        break
    ans.append([left1, right1])
    left1 += 1
    right1 -= 1

while True:
    if left2 >= right2:
        break
    ans.append([left2, right2])
    left2 += 1
    right2 -= 1
    
for i in range(m):
    print(*ans[i])
N,K = map(int, input().split())
x = 1

for i in range(N):
    x = min(x*2,x+K)

print(x)

### FIXED CODE ###

N = int(input())
K = int(input())
x = 1

for i in range(N):
    x = min(x*2,x+K)

print(x)
s = str(input())

import string

s = set(sorted(list(s)))
t = set(list(string.ascii_lowercase))
remain = t - s
remain = list(remain)

print(min(remain))

### FIXED CODE ###

s = str(input())

import string

s = set(sorted(list(s)))
t = set(list(string.ascii_lowercase))
remain = t - s
remain = list(remain)

if len(remain) > 0:
    print(min(remain))
else:
    print('None')
n, k = map(int, input().split())
aa = list(map(int, input().split()))
import numpy as np
aa = np.array(aa)

def mul(dd):
    mod = 10**9+7
    ret = 1
    for d in dd:
        ret = (ret*d)%mod
    return ret

def sol(aa, n, k):
    mod = 10**9+7
    aap = aa[aa>0]
    aam = aa[aa<0]
    if n == k:
        return mul(aa)
    if len(aap) + 2*(len(aam)//2) < k:
        return 0
    if len(aam) == n and k%2==1:
        aam.sort()
        aam = aam[::-1]
        return mul(aam[:k])

    aap.sort()
    aap = aap[::-1]
    aam.sort()

    ret=1
    if k%2 >0:
        k = k-1
        ret *= aap[0]
        aap = aap[1:]

    aap2 = [aap[2*i]*aap[2*i+1] for i in range(len(aap)//2)]
    aam2 = [aam[2*i]*aam[2*i+1] for i in range(len(aam)//2)]
    ip=0
    im=0
    for i in range(k//2):
        if ip < len(aap2) and aap2[ip] >= aam2[im]:
            ret = (ret * aap2[ip])%mod
            ip += 1
        else:
            ret = (ret * aam2[im])%mod
            im += 1
    return ret%mod

print(sol(aa, n, k))

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
aa = list(map(np.int64, input().split()))
aa = np.array(aa)

def mul(dd):
    mod = 10**9+7
    ret = 1
    for d in dd:
        ret = (ret*d)%mod
    return ret

def sol(aa, n, k):
    mod = 10**9+7
    aap = aa[aa>0]
    aam = aa[aa<0]
    if n == k:
        return mul(aa)
    if len(aap) + 2*(len(aam)//2) < k:
        return 0

    # マイナスのみ
    if len(aam) == n:
        aam.sort()
        if k%2==1:
            return mul(aam[-k:])
        else:
            return mul(aam[:k])

    aap = aa[aa>=0]
    aap.sort()
    aap = aap[::-1]
    aam.sort()

    ret=1
    if k%2 >0:
        k = k-1
        ret *= aap[0]
        aap = aap[1:]

    aap2 = [aap[2*i]*aap[2*i+1] for i in range(len(aap)//2)]
    aam2 = [aam[2*i]*aam[2*i+1] for i in range(len(aam)//2)]
    aap2.extend(aam2)
    aap2.sort(reverse=True)
    aap2 = [i%mod for i in aap2]
    return (ret*mul(aap2[:k//2]))%mod
print(sol(aa, n, k))
n = input()
s = 0
for i in range(len(n)) :
    s += int(n[i])
n = int(n)
if n % s == 0 :
    print('Yes')
else :
    print('No')


### FIXED CODE ###

s = input()
i = s.count("+")

print(2 * i - 4)
import math

N, M = map(int,input().split())
S = input()
T = input()

lcm = N*M//math.gcd(N, M)

ans = lcm

for n in range(N):
    for m in range(M):
        if (lcm//N)*n  == (lcm//M)*m:
            if S[n] != T[m]:
                ans = -1
                break
                
print(ans)

### FIXED CODE ###

from fractions import gcd
N,M=map(int,input().split())
S=list(input())
T=list(input())
L=gcd(N,M)
print(N*M//L if all([S[i*N//L]==T[i*M//L] for i in range(L)]) else "-1")
from fractions import lcm

def solve():
    a, b = list(map(int, input().split()))
    print(lcm(a, b))

if __name__ == "__main__":
    solve()

### FIXED CODE ###

from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def solve():
    a, b = list(map(int, input().split()))
    print(lcm(a, b))

if __name__ == "__main__":
    solve()
n = int(input())
for i in range(3, n+1):
    x = i
    if x % 3 == 0:
        print(' {0}'.format(i), end='')
        continue

    while x != 0:
        if x % 10 == 3:
            print(' {0}'.format(i), end='')
            break
        x // = 10

print()

### FIXED CODE ###

n = int(input())
for i in range(3, n + 1):
  if i % 3 == 0 or i % 10 == 3 or '3' in str(i):
      print('',i,end='')
print()
H, W = map(int, input().split())
MA = [list(input().strip()) for _ in range(H)]
VI = [[-1] * W for _ in range(H)]

kabe = 0
for i in range(H):
    kabe += MA[i].count("#")

from collections import deque


def bfs(ma, vi):
    Q = deque([(0,0)])
    sy, sx = (0,0)
    vi[sy][sx] = 0
    while True:
        q = Q.popleft()
        y, x = q
        if q == (H-1,W-1):
            return vi[y][x]
        for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            nq = y + dy, x + dx
            ny, nx = nq
            if 0 <= ny < H and 0 <= nx < W and vi[ny][nx] == -1:
                if ma[ny][nx] == '.':
                    Q.append(nq)
                    vi[ny][nx] = vi[y][x] + 1



print(H * W - kabe - bfs(MA, VI) - 1)

### FIXED CODE ###

H, W = map(int, input().split())
MA = [list(input().strip()) for _ in range(H)]
VI = [[-1] * W for _ in range(H)]

kabe = 0
for i in range(H):
    kabe += MA[i].count("#")

from collections import deque


def bfs(ma, vi):
    Q = deque([(0,0)])
    sy, sx = (0,0)
    vi[sy][sx] = 0
    while True:
        if Q == deque([]):
            return -1
        q = Q.popleft()
        y, x = q
        if q == (H-1,W-1):
            return vi[y][x]
        for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            nq = y + dy, x + dx
            ny, nx = nq
            if 0 <= ny < H and 0 <= nx < W and vi[ny][nx] == -1:
                if ma[ny][nx] == '.':
                    Q.append(nq)
                    vi[ny][nx] = vi[y][x] + 1


score = bfs(MA,VI)

if score != -1:
    print(H * W - kabe - score - 1)
else:
    print(-1)
s = list(input())
a = s[::2]
b = s[1::2]
if a.count(L) == 0 and b.count(R) == 0:
  print('Yes')
else:
  print("No")

### FIXED CODE ###

s = list(input())
a = s[::2]
b = s[1::2]
if a.count('L') == 0 and b.count('R') == 0:
  print('Yes')
else:
  print("No")
import numpy as np
N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

INF = 10**18
dp = np.array([INF] * 10**5)
h = np.concatenate([h, np.array([0]*(10**5 - len(h)))])

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])


### FIXED CODE ###

from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

INF = 10**18
dp = [INF] * (N + K)

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
        else:
            break
print(dp[N-1])
n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in num:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)

### FIXED CODE ###

n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in nums:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)