Harryxun/stf_run huggingface dataset:
h, w = map(int, input().split(" "))
s = []
for i in range(h):
    s.append(str(input()))
d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
ss = ["" for i in range(h)]
for i in range(h):
    for j in range(w):
        f = False
        if s[j][i] == ".":
            f = True
            continue
        for dx, dy in d:
            if 0 <= i + dx < w and 0 <= j + dy < h:
                if s[j + dy][i + dx] == "#":
                    f = True
                    break
        if not f:
            break
    if not f:
        break

if f:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

h, w = map(int, input().split(" "))
s = []
for i in range(h):
    s.append(str(input()))
d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
ss = ["" for i in range(h)]
for i in range(h):
    for j in range(w):
        f = False
        if s[i][j] == ".":
            f = True
            continue
        for dy, dx in d:
            if 0 <= i + dy < h and 0 <= j + dx < w:
                if s[i + dy][j + dx] == "#":
                    f = True
                    break
        if not f:
            break
    if not f:
        break

if f:
    print("Yes")
else:
    print("No")
s = input()
n = len(s)
p = 10 ** 9 + 7

# i = 0, ..., nについて
# dp[i][0] = i文字目まででありうる文字列の数（ABCなら1、AB?なら3）
# dp[i][1] = i文字目までに含まれるAの数
# dp[i][2] = i文字目までに含まれるABのパターン数
# dp[i][3] = i文字目までに含まれるABCのパターン数
dp = [[0 for j in range(4)] for i in range(n + 1)]
dp[0][0] = 1 # ''空の文字列は1パターン
for j in range(1, 4):
    dp[0][j] = 0  # 空の文字列にはAもABもABCも入っていない

print("dp[0] = {}".format(dp[0]))
for i in range(1, n + 1):
    m = 3 if s[i - 1] == '?' else 1

    for j in range(4):
        dp[i][j] = dp[i - 1][j] * m

    if s[i - 1] == 'A' or s[i - 1] == '?':
        dp[i][A] =  (dp[i][A] + dp[i - 1][0]) % p
    if s[i - 1] == 'B' or s[i - 1] == '?':
        dp[i][AB] = (dp[i][AB] + dp[i - 1][A]) % p
    if s[i - 1] == 'C' or s[i - 1] == '?':
        dp[i][ABC] = (dp[i][ABC] + dp[i - 1][AB]) % p

print(dp[n][ABC])

### FIXED CODE ###

s = input()
n = len(s)
p = 10 ** 9 + 7

q = s.count('?')
l_a = [0] * n  # l_a[i] := s[i]より左にあるAの数
l_x = [0] * n  # l_x[i] := s[i]より左にある?の数
r_c = [0] * n  # r_c[i] := s[i]より右にあるCの数
r_x = [0] * n  # r_x[i] := s[i]より右にある?の数

for i in range(1, n):  # 1〜n-1
    l_a[i] = l_a[i - 1] + int(s[i - 1] == 'A')
    l_x[i] = l_x[i - 1] + int(s[i - 1] == '?')
    r_c[n - i - 1] = r_c[n - i] + int(s[n - i] == 'C')
    r_x[n - i - 1] = r_x[n - i] + int(s[n - i] == '?')

ans = 0
pow_q = []
for i in range(0, 4):
    pow_q.append(max(1, 3 ** (q - i) % p))

for i in range(n):
    if s[i] == 'B':
        ans += (l_a[i] * r_c[i] % p) * pow_q[0] % p  # ABC
        ans += (l_x[i] * r_c[i] % p) * pow_q[1] % p # ?BC
        ans += (l_a[i] * r_x[i] % p) * pow_q[1] % p # AB?
        ans += (l_x[i] * r_x[i] % p) * pow_q[2] % p # ?B?
        ans %= p
    elif s[i] == '?':
        ans += (l_a[i] * r_c[i] % p) * pow_q[1] % p # A?C
        ans += (l_x[i] * r_c[i] % p) * pow_q[2] % p # ??C
        ans += (l_a[i] * r_x[i] % p) * pow_q[2] % p # A??
        ans += (l_x[i] * r_x[i] % p) * pow_q[3] % p # ???
        ans %= p

print(ans)
import sys
def solve():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    m = int(ws[1])
    ls_a = []
    ls_b = [[] for i in range(n)]
    for i in range(M):
        p,y = map(int, sys.stdin.readline().strip().split())
        ls_a.append([p,y])
        ls_b[p-1].append(y)
    for i in range(n):
        ls_b[i].sort()
    for i in range(m):
        print(str(ls_a[i][0]).zfill(6) + str(ls_b[ls_a[i][0]-1].index(ls_a[i][1])+1).zfill(6))
solve()

### FIXED CODE ###

N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了
 
PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M
 
for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for i in range(M):
  	print(w[i])
N,X = map(int,input().split())
L = list(map(int,input().split()))
count = 0
var = 0
for i in range(X):
    count += 1
    var +=L [i]
    if var > X:
        break
print(count)


### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))
count = 1
var = 0
for i in range(N):
    if i >= N:
        break
    var += L[i]
    if var > X:
        break
    count += 1
print(count)
r, g, b = map(int, input(),split())
if g*10 + b % 4 == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

r, g, b = map(int, input().split())
if (g*10 + b)% 4 == 0:
    print("YES")
else:
    print("NO")
inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conditions = {}
for i in range(n):
  inputs = [int(x) for x in input().split()]
  if inputs[0] in conditions.keys():
    conditions[inputs[0]].append(inputs[1])
  else:
    conditions[inputs[0]] = [inputs[1]]

for day in conditions.keys():
  conditions[day].sort(reverse=True)

print(conditions)

ans = 0
candidates = []
for reversed_day in range(1, m+1):
  if reversed_day in conditions.keys():
    candidates.append(conditions[reversed_day])

  cand_len = len(candidates)
  if cand_len == 0:
    continue
  maxval, maxidx = 0, 0
  for i in range(cand_len):
    if candidates[i][0] > maxval:
      maxval = candidates[i][0]
      maxidx = i
  ans += candidates[maxidx].pop(0)
print(ans)

### FIXED CODE ###


import collections
import heapq

inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conditions = collections.deque([])
for i in range(n):
  conditions.append([int(x) for x in input().split()])

conditions = sorted(conditions)

cnt, ans = 0, 0
candidates = []
for reversed_day in range(1, m + 1):
  while cnt < len(conditions) and conditions[cnt][0] <= reversed_day:
    heapq.heappush(candidates, -conditions[cnt][1])
    cnt += 1

  if len(candidates) == 0:
    continue
  ans -= heapq.heappop(candidates)

print(ans)
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    u,v=u-1,v-1
    G[u].append((v,w))
    G[v].append((u,w))
res=[-1]*N
res[0]=0
def dfs(v,p,c):
    res[v]=c
    for nv,w in G[v]:
        if nv==p:
            continue
        if w&1:
            dfs(nv,v,1-c)
        else:
            dfs(nv,v,c)
dfs(0,-1,0)
for i in res:
    print(i)


### FIXED CODE ###

N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    u,v=u-1,v-1
    G[u].append((v,w))
    G[v].append((u,w))
reached=[0]*N
stack=[0]
reached[0]=[1]
res=[-1]*N
res[0]=0
while(stack):
    v=stack.pop()
    for nv,w in G[v]:
        if reached[nv]:
            continue
        if w & 1:
            res[nv]=1-res[v]
        else:
            res[nv]=res[v]
        stack.append(nv)
        reached[nv]=1
for i in res:
    print(i)
s = input()
acgt = ["A","C","G","T"]
res = []
parts = ""

for i in range(len(s)):
    parts = ""
    for c in s[i:]:
        if c in acgt:
            parts += c
        else:
            res.append(len(parts))
            break

print(max(res))

### FIXED CODE ###

s = input()
acgt = ["A","C","G","T"]
res = []
parts = ""

for i in range(len(s)):
    parts = ""
    for c in s[i:]:
        if c in acgt:
            parts += c
        else:
            break
    res.append(len(parts))

print(max(res))
a = list(map(int, input().split()))
queuekey = []
queuetime = []

for i in range(0, a[0]):
    tmp = list(input().split())
    queuekey.append(tmp[0])
    queuetime.append(int(tmp[1]))

spentTime = 0
while len(queue) > 0:
    if queuetime[0] < a[1]:
        spentTime += queuetime[0]
        print(queuekey[0], end="")
        print(' ', end="")
        print(spentTime)
        queuekey.pop(0)
        queuetime.pop(0)
    else:
        spentTime += a[1]
        queuetime[0] -= a[1]
        queuetime.append(queletime[0])
        queuekey.append(quelekey[0])
        queuetime.pop(0)
        queuekey.pop(0)

        
    

### FIXED CODE ###

a = list(map(int, input().split()))
queuekey = []
queuetime = []

for i in range(0, a[0]):
    tmp = list(input().split())
    queuekey.append(tmp[0])
    queuetime.append(int(tmp[1]))

spentTime = 0
while len(queuetime) > 0:
    if queuetime[0] <= a[1]:
        spentTime += queuetime[0]
        print(queuekey[0], end="")
        print(' ', end="")
        print(spentTime)
        queuekey.pop(0)
        queuetime.pop(0)
    else:
        spentTime += a[1]
        queuetime[0] -= a[1]
        queuetime.append(queuetime[0])
        queuekey.append(queuekey[0])
        queuetime.pop(0)
        queuekey.pop(0)
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)



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

lcm = lcm_list(A_line)
mother = sum(map(lambda x: lcm//x, A_line))

print(lcm/mother)

### FIXED CODE ###

import math
import fractions

def gcd_list(numbers):
    for i in range(1, len(numbers)):
        ans = fractions.gcd(ans, numbers[i])
    return ans

def lcm_list(numbers):
    ans = numbers[0]
    for i in range(1, len(numbers)):
        ans = ans * numbers[i] // fractions.gcd(ans, numbers[i])
    return ans



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

lcm = lcm_list(A_line)
mother = sum(map(lambda x: lcm//x, A_line))

print(lcm/mother)
A=input()
B=input()
C=input()
s="a"
while:
  print(str(len(A))+str(len(B))+str(len(C)))
  if s=="a":
    s=A[0]
    A=A[1:]
    if len(A)==0:
        print("A")
        break
  elif s=="b":
    s=B[0]
    B=B[1:]
    if len(B)==0:
        print("B")
        break
  else:
    s=C[0]
    C=C[1:]
    if len(C)==0:
        print("C")
        break


### FIXED CODE ###

A=input()
B=input()
C=input()
s="a"
while (len(A)!=0 or s!="a") and (len(B)!=0 or s!="b") and (len(C)!=0 or s!="c"):
  if s=="a":
    s=A[0]
    A=A[1:]
  elif s=="b":
    s=B[0]
    B=B[1:]
  else:
    s=C[0]
    C=C[1:]
if len(A)==0 and s=="a":
    print("A")
elif len(B)==0 and s=="b":
    print("B")
else:
    print("C")
mport math
a, b, x = map(int, input().split())
i = a**3
j = 2*(a*a*b-x)
tan1 = i/j
deg = math.degrees(math.atan(tan1))
if x < a*a*b/2:
    tan2 = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan2))

print(90-deg)

### FIXED CODE ###

import math
a, b, x = map(int, input().split())

if x < a*a*b/2:
    tan = 2*x / (a*b*b)
    deg = math.degrees(math.atan(tan))
    print(90-deg)
elif x == a*a*b:
    print(0)
else:
    i = a**3
    j = 2*(a*a*b-x)
    tan = i/j
    deg = math.degrees(math.atan(tan))
    print(90-deg)
patterns = ['dream', 'dreamer' , 'erase', 'eraser'] 

def check(string):
  if len(string) == 0:
    return True
  if string[0:5] == 'dream':
    if check(string[5:]):
      return True
    if check(string[7:]):
      return True
  elif string[0:5] == 'erase':
    if check(string[5:]):
      return True
    if check(string[6:]):
      return True
  else:
    return False
  
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")


### FIXED CODE ###

# dream = list(reversed('dream'))
# dreamer = list(reversed('dreamer'))
# erase = list(reversed('erase'))
# eraser = list(reversed('eraser'))

# def check(string):
#   l = len(string)

#   if l == 0:
#     return True
  
#   if l < 5:
#     return False

#   if string[0:5] == dream:
#     return check(string[5:])
#   if l >= 7 and string[0:7] == dreamer:
#     return check(string[7:])
#   if string[0:5] == erase:
#     return check(string[5:])
#   if l >= 6 and string[0:6] == eraser:
#     return check(string[6:])
      
#   return False

# S = input()
# S = list(reversed(S))
# if check(S):
#   print("YES")
# else:
#   print("NO")

s = input()
 
while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break
 
print('NO' if len(s) > 0 else 'YES')
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 3*10**5
for i range(N):
  if i + K > N:
    break
  if A[i]*A[i+K] <= 0:
    if abs[i] < abs[i+K]:
      ans = min(ans, abs[i]*2+abs[i+K])
    else:
      ans = min(ans, abs[i]+abs[i+K]*2)
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 10**9
for i in range(N-K+1):
  if A[i]*A[i+K-1] <= 0:
    if abs(A[i]) < abs(A[i+K-1]):
      ans = min(ans, (abs(A[i]))*2+A[i+K-1])
    else:
      ans = min(ans, abs(A[i])+A[i+K-1]*2)
  else:
    if abs(A[i]) < abs(A[i+K-1]):
      ans = min(ans, abs(A[i+K-1]))
    else:
      ans = min(ans, abs(A[i]))
print(ans)
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]

p_idx=0
q_idx=0
plen=len(p)
qlen=len(q)
for i in range(c):
    #処理が終わる時
    if p[p_idx]>r[i] and q[q_idx]>r[i]:
        break
    #全部入れ替わる
    if p_idx==plen and q_idx==qlen:
        break
    #どちらかが全部入れ替わる
    #それ以外
    if p[p_idx]<=q[q_idx] or q_idx==qlen:
        if p[p_idx]>r[i]:
            break
        else:
            p[p_idx]=r[i]
            p_idx+=1
    if q[q_idx]<=p[p_idx] or p_idx==plen:
        if q[q_idx]>r[i]:
            break
        else:
            q[q_idx]=r[i]
            q_idx+=1

ans=sum(p)+sum(q)
print(ans)

### FIXED CODE ###

x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]
p.extend(q)
p.sort()

idx=0
for i in range(len(p)):
    if p[i]>r[idx]:
        break
    else:
        p[i]=r[idx]
        idx+=1
        if c==idx:
            break

print(sum(p))
def calculateTotalAmount(x, y):
    totalAmount = 0
    if x == 1:
        if y == 1:
            totalAmount = 300000 + 300000 + 400000
        elif y == 2:
            totalAmount = 300000 + 200000
        elif y == 3:
            totalAmount = 300000 + 100000
        else:
            totalAmount = 300000
    elif x == 2:
        if y == 1:
            totalAmount = 200000 + 300000
        elif y == 2:
            totalAmount = 200000 + 200000
        elif y == 3:
            totalAmount = 200000 + 100000
        else:
            totalAmount = 200000
    elif x == 3:
        if y == 1:
            totalAmount = 100000 + 300000
        elif y == 2:
            totalAmount = 100000 + 200000
        elif y == 3:
            totalAmount = 100000 + 100000
        else:
            totalAmount = 100000
    else:
        if y == 1:
            totalAmount = 300000
        elif y == 2:
            totalAmount = 200000
        elif y == 3:
            totalAmount = 100000
        else:
            totalAmount = 0
    return totalAmount


X = int(input('input the place in coding contest: '))
Y = int(input('input the place in robot maneuver: '))

totalAmount = calculateTotalAmount(X, Y)
print(totalAmount)

### FIXED CODE ###

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

totalAmount = 0
first = 300000
second = 200000
third = 100000
extraPrice = 400000


if X == 1:
    totalAmount = first
    pass
elif X == 2:
    totalAmount = second
    pass
elif X == 3:
    totalAmount = third
    pass
elif X < 1 or X > 3:
    totalAmount = 0
    pass

if Y == 1:
    totalAmount = totalAmount + first
    pass
elif Y == 2:
    totalAmount = totalAmount + second
    pass
elif Y == 3:
    totalAmount = totalAmount + third
    pass
elif Y < 1 or Y > 3:
    totalAmount = totalAmount + 0
    pass

if X == 1 and Y == 1:
    totalAmount = totalAmount + extraPrice

print(totalAmount)
def resolve():
    a,b,c=map(int, input().split())
    cnt=0
    if a+b>=c-1:
        print(b+c)
    else:
        print(a+b+1+)
resolve()

### FIXED CODE ###

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

def resolve():
    a,b,c=map(int, input().split())
    cnt=0
    if a+b>=c-1:
        print(b+c)
    else:
        print(a+b+1+b)
resolve()
s = input()
s = list(s)
s_rev = list(reversed(s))
n = len(s)


r = 0
for i in range(n):
    if s[i] == "R":
        r += 1
        continue
    if s[i] == "L":
        if r % 2 == 0:
            r_point[i] = r//2
            r_point[i+1] = r//2
        else:
            r_point[i] = r//2 + 1
            r_point[i+1] = r//2
        r = 0

el = 0
for i in range(n):
    if s_rev[i] == "L":
        el += 1
        continue
    if s_rev[i] == "R":
        if el % 2 == 0:
            l_point[i] = el//2
            l_point[i+1] = el//2
        else:
            l_point[i] = el//2 + 1
            l_point[i+1] = el//2
        el = 0

l_point = list(reversed(l_point))

print(r_point)
print(l_point)

for lp, rp in zip(l_point[1:], r_point[:-1]):
    print(str(lp+rp), end=" ")


### FIXED CODE ###

S = input()

ans = []
cnt = 0
rl = S[0]

if S[-1] == 'R':
    S += 'L'
else:
    S += 'R'

for s in S:
    if s == rl:
        cnt += 1
    elif rl == 'R' and s == 'L':
        for i in range(cnt-1):
            ans.append(0)
        ans.append(cnt)
        cnt = 1
        rl = 'L'
    else:
        r = ans.pop(-1)
        l = cnt
        ans.append((r+l)//2)
        ans.append((r+l)//2)
        if (r+l) % 2 == 1 and r % 2 == 0:
            ans[-1] += 1
        elif (r+l) % 2 == 1 and r % 2 == 1:
            ans[-2] += 1
        for i in range(l-1):
            ans.append(0)
        cnt = 1
        rl = 'R'

print(*ans)
def d_face_produces_unhappiness():
    N, K = [int(i) for i in input().split()]
    S = input()
    before_char = S[0]
    t = []
    v = 0
    for s in S + '*':
        if s != before_char:
            t.append(v)
            v = 1
        else:
            v += 1
        before_char = s
    t.sort(reverse=True)
    for i in range(K):
        t[i] += 2
    return min(sum([e - 1 for e in t]), N - 1)

print(d_face_produces_unhappiness())

### FIXED CODE ###

def d_face_produces_unhappiness():
    N, K = [int(i) for i in input().split()]
    S = input()
    before_char = S[0]
    t = []
    v = 0
    for s in S + '*':
        if s != before_char:
            t.append(v)
            v = 1
        else:
            v += 1
        before_char = s
    t.sort(reverse=True)
    for i in range(min(K, len(t))):
        t[i] += 2
    return min(sum([e - 1 for e in t]), N - 1)

print(d_face_produces_unhappiness())
n,k=map(int,input().split())
i=0
while k**i<n:
  i+=1
print i

### FIXED CODE ###

n,k=map(int,input().split())
i=0
while k**i<=n:
  i+=1
print(i)
A,B,C,D = map(int,input().split())
import math
lcm = int( C*D / ( math.gcd(C,D) ) )

first_c = int( ( A - 1) / C)
first_d = int( ( A - 1) / D)
first_cd = int( ( A - 1) / lcm )
first = ( A - 1 ) - ( first_c + first_d - first_cd )

end_c = int( B / C)
end_d = int( B / D)
end_cd = int( B / lcm )
end_ = B - ( end_c + end_d - end_cd )

print(end_ - first)

### FIXED CODE ###

A,B,C,D = map(int,input().split())
import fractions
lcm = int( C*D / ( fractions.gcd(C,D) ) )

first_c = ( A - 1) // C
first_d = ( A - 1) // D
first_cd = ( A - 1) // lcm 
first = ( A - 1 ) - ( first_c + first_d - first_cd )

end_c = B // C
end_d = B // D
end_cd = B // lcm 
end_ = B - ( end_c + end_d - end_cd )

print(end_ - first)
N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')
# for i in range(1,N-1):
#     for j in range(i+1,N):
#         if S[i-1] != S[j-1]:
#             for k in range(j+1,N+1):
#                 if S[i-1]!=S[k-1] and S[j-1]!=S[k-1] and j-i!=k-j:
#                     cnt += 1
for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if k>j and k-1<=N:
            if S[i-1]==S[j-1] or S[i-1]==S[k-1] or S[j-1]==S[k-1] :
                cnt -= 1


print(cnt)

### FIXED CODE ###



N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')

for i in range(N-2):
    for j in range(i,N-1):
        k = 2*j-i
        if  k<=N-1:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] :
                cnt -= 1


print(cnt)
# -*- coding: utf-8 -*-
import sys
from functools import reduce
from math import gcd
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    # 最小公倍数
    lcd = reduce(lambda i,j: i*j//gcd(i,j), A, 1)
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from functools import reduce
from fractions import gcd
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    lcd = reduce(lambda i,j: i*j//gcd(i,j), A, 1)
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
import sympy

def func(n, history):
    l = sympy.divisors(n)
    for i in l[1:]:
        if n == i:
            history.append(i)
            return history
        if i in history:
            continue
        history.append(i)
        try:
            _ = n // i
        except:
            return history
        func(_, history)
        break
    return history

N = int(input())
if N == 0:
    print(0)
else:
    h = func(N, [])
    print(len(set(h)))

### FIXED CODE ###

history = set([])

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def func(n):
    if n == 1:
        return 
    l = make_divisors(n)
    for i in sorted(l[1:]):
        if i in history:
            continue
        if len(factorization(i)) > 1:
            continue
        history.add(i)
        _ = n // i
        func(_)
        break
    return

N = int(input())
if N == 0:
    print(0)
elif N == 1:
    print(0)
else:
    func(N)
    print(len(history))
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

if N == 1:
    Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]

elif N == 2:
    if xyh[0][2] > xyh[1][2]:
        Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]
    else:
        Cx, Cy, H = xyh[1][0], xyh[1][1], xyh[1][2]

else:
    flag = False
    for i in range(101):
        for j in range(101):
            sampleH = xyh[0][2] + abs(i-xyh[0][0]) + abs(j-xyh[0][1])
            for k in range(1, N):
                flag = True
                if xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1]) != sampleH:
                    flag = False
                    break
            if flag:
                Cx, Cy, H = i, j, sampleH
                break
        if flag:
            break

print(Cx, Cy, H)


### FIXED CODE ###

N = int(input())
xyh = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        xyh.append([x, y, h])

if len(xyh) == 1:
    Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]

elif len(xyh) == 2:
    if xyh[0][2] > xyh[1][2]:
        Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]
    else:
        Cx, Cy, H = xyh[1][0], xyh[1][1], xyh[1][2]

else:
    flag = False
    for i in range(101):
        for j in range(101):
            sampleH = xyh[0][2] + abs(i-xyh[0][0]) + abs(j-xyh[0][1])
            for k in range(1, len(xyh)):
                flag = True
                if xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1]) != sampleH:
                    flag = False
                    break
            if flag:
                Cx, Cy, H = i, j, sampleH
                break
        if flag:
            break

print(Cx, Cy, H)
a=input()
p1=a[0]
p2=a[1]
p3=a[3]

if p1==p2==p3:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

a=input()
p1=a[-1]
p2=a[0]
p3=a[1]
 
if p1==p2==p3:
  print("No")
else:
  print("Yes")