peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

X = sum(a)
ans = float("inf")
x = 0
for i in range(n):
    x += a[i]
    if (i + 1) < n:
        ans = min(ans, abs(X - 2 * x))

print(ans)
# Judge status: Accepted
s = input()
l = len(s) // 2
a = s[:l]
b = s[:-(l + 1):-1]
count = 0
for i, j in zip(a, b):
    if i != j:
        count += 1
print(count)
# Judge status: Accepted
from collections import Counter
d={chr(i):0 for i in range(2)}
s=Counter(input())
d=d.update(s)
print(min(s["0"],s["1"])*2)
# Judge status: Accepted
h = int(input().strip())

c=0
while(h):
    h=h//2
    c+=1

ans=(1-2**c)//(1-2)
print(ans)
# Judge status: Wrong Answer
N = int(input())
C = list(input())
N1 = int(N/2)
C1 = C[0:N1]
C2 = C[N1:N]
count = 0
if (C1.count('W') == C2.count('R')):   #左右対象のとき
    count = C1.count('W')
elif(C1.count('R') == C2.count('W')):
    count = C.count('W')
print(count)
# Judge status: Wrong Answer
s=input()
YY=[]
MM=["01","02","03","04","05","06","07","08","09","10","11","12"]

for i in range(13,100):
    YY.append(str(i))

if s[:2] in YY and s[2:] in MM:
    print("YYMM")
elif s[:2] in MM and s[2:] in YY:
    print("MMYY")

elif s[:2] in MM and s[2:] in MM:
    print("AMBIGUOUS")
elif s[:2] in YY and s[2:] in YY:
    print("NA")
# Judge status: Accepted
X = int(input())

l = range(-10**3,10**3)

for i in l:
  for j in l:
    if i**5 - j**5 == X:
      print(str(i) + " " + str(j))
      exit()
# Judge status: Accepted
x = input()

ans = 0
s_cnt = 0

for i in range(len(x)):
    if s_cnt == 0:
        if x[i] == 'T':
            ans += 1
        else:
            s_cnt += 1
    else:
        if x[i] == 'T':
            s_cnt -= 1
        else:
            s_cnt += 1

if s_cnt > 0:
    ans += s_cnt

print(ans)
# Judge status: Accepted
import sys
A,B,C,D = map(int,input().split())

for i in range(1000):
    C -= B
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    if A <= 0:
        print("No")
        exit()
# Judge status: Accepted
n = int(input())
s = input()

slist = [0]
sval = 0
for i in s :
    if i == "I":
        sval += 1
        slist.append(sval)
    else:
        sval -= 1
        slist.append(sval)
print(max(slist))
# Judge status: Wrong Answer
a, b, k = map(int, input().split())
takahasi = max(0, a - k)
aoki = max(0, b - (k - a))
print(takahasi, aoki)
# Judge status: Accepted
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


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

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
ab_dividers = sorted(a_dividers & b_dividers)
print(ab_dividers[-K])
# Judge status: Accepted
S = input()
if S == "ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Accepted
# -*- coding -*-
a = int(input())
b = int(input())

if a + b == 3:
  print(3)
elif a + b == 4:
  print(2)
else:
  print(1)
# Judge status: Accepted
S = int(input())
mod = 10**9+7
dp=[0]*(S+1)
dp[0]=1
for i in range(1,S+1):
  for j in range(0,(i-3)+1):
    dp[i] += dp[j]
    dp[i] %= mod
    
print(dp[S])
# Judge status: Accepted
x,k,d=map(int,input().split())
x=abs(x)
ans=0
if x>k*d:
    ans=x-(k*d)
else:
    if k%2==(x//d)%2:
        ans=x%d
    else:
        ans=abs(x%d-d)
print(ans)
# Judge status: Accepted
from collections import deque
s=input()
n = int(input())

f=False
q= deque(s)

for _ in range(n):
    i = input()

    if i[0] == '1': f=False if f else True
    else:
        _,a,b =i.split()
        
        if f :
            if a == '1':q.append(b)
            else:q.appendleft(b)
        else:
            if a == '1':q.appendleft(b)
            else:q.append(b)

if f: q.reverse()

for i in q:print(i,end='')
# Judge status: Accepted
s = input()
List = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
#print(List.index(s))
print(7-List.index(s))
# Judge status: Accepted
from collections import deque

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

d = deque(data)
d.appendleft(0)
d.pop()

bet = [i-j for i, j in zip(data, d)]

bet[0] += k - data[-1]

print(k - max(bet))
# Judge status: Wrong Answer
import sys
n = int(input())
if n % 2 == 1:
  print(0)
  sys.exit()
m = n/2
count = 0
i = 1
while m >= 5 ** i:
  count += (m // (5 ** i))
  i += 1
print(int(count))
# Judge status: Accepted
import numpy as np
import math as m

def main(**kwargs):
    res = -1
    now = 1263

    while now > 0:
        now -= 1
        
        if (int(now * 0.08) == a and int(now * 0.1) == b):
            res = now

    return res

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    a, b, *_ = cin

    cout = main(a=a, b=b)
    print(cout)
# Judge status: Wrong Answer
n=int(input())
if n%2==1:
    print(0)
    exit(0)

k=n//2

from math import floor

ans=0
deno=5
while deno<=k:
    ans+=k//deno
    deno*=5

print(ans)
# Judge status: Accepted
num = list(map(int,input().split()))
for i in range(int(input())):
    tmp = max(num)
    num[num.index(tmp)] = tmp*2
print(sum(num))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

ans = []
s = A[0]
n = 1
for i in range(1, N):
  if len(ans) == 2: break
  if A[i] == s:
    n += 1
    if n == 2 or n == 4:
      ans.append(s)
  else:
    s = A[i]
    n = 1
print(ans[0] * ans[1] if len(ans) != 0 else 0)
# Judge status: Accepted
N, K = list(map(int,input().split()))
p = list(map(int,input().split()))

a = []
#各サイコロの期待値のリストaを作成
for i in range(N):
  a.append((p[i]+1)/2)
#累積和のリストSの作成
S = [0]
for i in range(N):
  S.append(S[i]+a[i])
#隣接N個のサイコロの期待値の和のリストansの作成
ans = []
for i in range(N-K+1):
  ans.append(S[i+K]-S[i])
  
print(max(ans))
# Judge status: Accepted
import itertools
N,M,Q=map(int,input().split())
a=[]
for _ in range(Q):
    b=list(map(int,input().split()))
    a.append(b)
s=[]
for i in range(1,M+1):
    s.append(i)
alist=list(itertools.combinations_with_replacement(s, r=N+1))


tmp=0
for j in alist:
    s=0
    for i in range(Q):
        j=list(j)
        if j[a[i][1]]-j[a[i][0]]==a[i][2]:
            s+=a[i][3]
    tmp=max(tmp,s)
print(tmp)
# Judge status: Wrong Answer
n = int(input())
p = input().split()

cnt = 0
for i in range(0, n-2):
    print(p[i])
    if (p[i] < p[i+1] < p[i+2]) or (p[i] > p[i+1] > p[i+2]):
        cnt += 1
print("cnt", cnt)
# Judge status: Wrong Answer
from collections import Counter

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

c = Counter(A)
hen = [key for key, val in c.items() if val > 1]

l = max(hen) if hen else 0
if l != 0:
    hen.remove(l)
    s = max(hen) if hen else 0
else:
    s = 0

print(l * s)
# Judge status: Wrong Answer
n=int(input())
cnt=0
c=0
d=0
e=0
if n==0:
    print(0)
if int(n/500)>0:
    cnt=int(n/500)
    n=n%500
if int(n/100)>0:
    d=int(n/100)
    n=n%100
if int(n/50)>0:
    e=int(n/50)
    n=n%50
if int(n/5)>0:
    c=int(n/5)
    n=n%5
print(cnt*1000+c*5+d*0+e*0)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(n-2):
    if a[i]<a[i+1]<a[i+2] or a[i]>a[i+1]>a[i+2]:
        c+=1
print(c)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
if b < c or d < a:
    print(0)
elif a <= c and d <= b:
    print(d-c)
elif c <= a and b <= d:
    print(b-a)
elif a <= c and b <= d:
    print(b-c)
elif c <= a and d <= b:
    print(d-a)
# Judge status: Accepted
x, y=map(int, input().split())
c1=x<=y
c2=x*y>=0
a=0
if c1 and c2: # 正正か負負でｘ＜Y
  print(y-x)
elif c1 and not c2: # 負正でx<y
  print(abs(y-abs(x))+1)
elif not c1 and c2: # 正正か負負でx>y
  if x*y==0:
    a=1
  else:
    a=2
  print(x-y+a)
elif not c1 and not c2: # 正負でx>y
  print(abs(x-abs(y))+1)
# Judge status: Accepted
print("Yes" if int(input()) >= 30 else "No")
# Judge status: Accepted
x, y = map(int, input().split())

if x % y == 0:
    ans = -1
else:
    ans = x
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=a[0]
w=n//2
for aa in a[1:w]:
  ans+=aa*2
if n%2!=0:
  ans+=a[w]
print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = []
i = 0
while i+1<N:
    if len(b)==2:
        break
    if a[i] == a[i+1]:
        b += [a[i]]
        i += 2
    else:
        i += 1

if len(b)<2:
    print(0)
else:
    print(b[0]*b[1])
# Judge status: Accepted
s,t=open(0)
m=len(t:=t[:-1])
for i in range(len(s)):
 if all(c in'?'+d for c,d in zip(s[-i-m:],t)):s=s.replace(*'?a');exit(print(s[:-i-m]+t+s[-i:]))
print('UNRESTORABLE')
# Judge status: Accepted
from math import gcd
def resolver(X):
    i = 1
    while True:
        if (360 * i) % X == 0:
            return (360 * i) // X
        i += 1



def main():
    X = int(input())
    ans = resolver(X)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, c, d = map(int, input().split())
l = [a*c, a*d, b*c, b*d]
print(max(l))
# Judge status: Accepted
x=int(input())
while True:
  cnt=0
  for i in range(2,x//2):
    if x%i==0:
      cnt+=1
      break
  if cnt==0:
    print(x)
    break
  elif cnt==1:
    x+=1
    continue
# Judge status: Accepted
N,M=map(int,input().split())

def check(i):
    if M<i*2:
        return False
    if N+(M-i*2)//2<i:
        return False
    return True

r=M//2+1
l=0
while r-l>1:
    mid=(r+l)//2
    #print(mid,check(mid))
    if check(mid):
        l=mid
    else:
        r=mid
print(l)
# Judge status: Wrong Answer
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()
if x[n - 1] < y[0] and X <= y[0] and x[n - 1] <= Y:
    print("No War")
else:
    print("War")
# Judge status: Accepted
# encoding="UTF-8"

S,W = input().split()
S=int(S)
W=int(W)
if W >= S:
    print("unsafe")
elif W < S:
    print("safe")
# Judge status: Accepted
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()

pas = 1
last_bus = t[0] + k
ans = 1

for i in t[1:]:
  if i <= last_bus and pas < c:
    pas +=1
  else:
    ans +=1
    pas =1
    last_bus = i + k
    
    
print(ans)
# Judge status: Accepted
import sys
n, *CSF = list(map(int, sys.stdin.read().split()))
C = CSF[::3]
S = CSF[1::3]
F = CSF[2::3]


def solve(x):
    cur = 0
    for i in range(x, n - 1):
        y = cur % F[i]
        if S[i] > cur:
            cur = S[i] + C[i]
        elif y == 0:
            cur += C[i]
        else:
            cur += (F[i] - y) + C[i]
    return cur


for i in range(n - 1):
    print(solve(i))
print(0)
# Judge status: Wrong Answer
a = int(input("整数を入力してください"))
answer = a+a*a+a*a*a
print("答えは",answer)
# Judge status: Wrong Answer
n = int(input())
x = list(map(int, input().split()))
x.sort()
mid = x[len(x)//2]
strt = mid
res = 10**7
if strt>n//2:
  strt = n//2
  for i in range(strt,x[-1]):
    tmp = 0
    for j in x:
      tmp += (j-i)**2
    res = min(tmp,res)
else:
  strt = 0
  for i in range(strt,mid):
    tmp = 0
    for j in x:
      tmp += (j-i)**2
    res = min(tmp,res)
print(res)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))
L.sort()
def find(arr, x):
  if arr[0] >= x:
    return 0
  if arr[-1] < x:
    return len(arr)
  
  l = 0
  h = len(arr)
  
  while h - l > 1:
    m = (l+h) // 2
    if arr[m] < x:
      l = m
    else:
      h = m
  return h

ans = 0

for i in range(N-2):
  for j in range(i+1, N-1):
    x = L[i] + L[j]
    temp = find(L[j+1:], x)
    ans += temp
print(ans)
# Judge status: Accepted
a, b = map(int,input().split())
s = input()
n = s[:a] + s[a+1:]
print('Yes' if s[a]=='-' and n.isdigit() else 'No')
# Judge status: Accepted
X=int(input())

for i in range(10**5):
  if i*(i+1)//2>=X:
    print(i)
    break
# Judge status: Accepted
# Panasonic2020 B

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

if h == 1 or w == 1:
    print(1)
elif (h * w) % 2:
    print(1 + (h * w) // 2)
else:
    print(h * w // 2)
# Judge status: Accepted
N = int(input())
is_approved = True
l = list(map(int, input().split()))
for i in l:
    if i % 2 == 0:
        if not (i % 5 == 0 or i % 3 == 0):
            is_approved = False
            break
print('APPROVED' if is_approved else 'DENIED')
# Judge status: Accepted
from fractions import gcd
from math import sqrt

a,b = map(int,input().split())
n = gcd(a,b)
k = n
s = set()
s.add(1)
for i in range(2,int(sqrt(n))+1):
  while n%i == 0:
    n = n//i
    s.add(i)
  if n == 1:
    break
s.add(n)
print(len(s))
# Judge status: Accepted
k = int(input())
a,b = [int(x) for x in input().split()]
ans=False
for i in range(a,b+1):
    if(i%k==0):
        ans = True
        break

if(ans):
    print("OK")
else:
    print("NG")
# Judge status: Accepted
n, q = map(int, input().split())
s = input()
ans = [0]
for i in range(1, n):
  if s[i - 1:i + 1] == "AC":
    ans.append(ans[-1] + 1)
  else:
    ans.append(ans[-1])
for _ in range(q):
  l, r = map(int, input().split())
  print(ans[r - 1] - ans[l - 1])
# Judge status: Accepted
s = input()

ans = 'Good'

for i in range(3):
   if s[i] == s[i+1]:
         ans = 'Bad'
         break

print(ans)
# Judge status: Accepted
A,B = map(int,input().split())
if A > 8 or B > 8:
  print(":(")
else:
  print("Yay!")
# Judge status: Accepted
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
Z = sorted([x+y for x,y in A])
W = sorted([x-y for x,y in A])

print(max(Z[-1]-Z[0], W[-1]-W[0]))
# Judge status: Accepted
a, b, x = map(int, input().split())
if a + b >= x:
    if a <= x:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
# Judge status: Accepted
n = int(input())

count_list = []
for i in range(10):
    count_list.append([0] * 10)

for i in range(1, n + 1):
    i_str = str(i)
    j = int(i_str[0])
    k = int(i_str[-1])
    count_list[j][k] += 1

ans = sum([count_list[i][j] * count_list[j][i] for i in range(1, 10) for j in range(1, 10)])
print(ans)
# Judge status: Accepted
A, B = list(map(int,input().split()))
if A == 1:
    A = 14
if B == 1:
    B = 14

print('Alice' if A > B else 'Bob' if A < B else 'Draw')
# Judge status: Accepted
x, y = map(int, input().split())
if x % y == 0:
    print(-1)
else:
    print(x)
# Judge status: Wrong Answer
N, M = map(int, input().split())
print(max(N+(M-N*2)//4, N))
# Judge status: Accepted
# A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
# B = [int(input()) for _ in range(n)]
A = list(map(int, input().split()))
# a, b = map(int, input().split())
# S = input()


def choose2(n):
    return n*(n-1)//2


cnt = [0 for _ in range(n+1)]
for i in range(n):
    cnt[A[i]-1] += 1
total = 0
for i in range(n):
    total += choose2(cnt[i])
for i in range(n):
    ans = total
    ans -= choose2(cnt[A[i]-1])
    ans += choose2(cnt[A[i]-1]-1)
    print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
l=1
r=n
for i in range(m):
  li,ri=map(int,input().split())
  l = max(l,li)
  r = min(r,ri)
print(max(r-l+1,0))
# Judge status: Accepted
a,b,c=map(int,input().split())
if a+b+c>=22:
  print("bust")
else:
  print("win")
# Judge status: Wrong Answer
K, X = map(int, input().split(" "))

if 500*K>X:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
ans=0
for i in range(n):
    a=0
    a+=sum(a1[:i+1])
    a+=sum(a2[i:])
    ans=max(ans,a)
print(ans)
# Judge status: Accepted
A,B,C=list(map(int, input().split()))
K=int(input())

m=max(A,B,C)
print(A+B+C-m+m*(2**K))
# Judge status: Accepted
N = int(input())
p = list(map(int, input().split()))
diff = 0
for i in range(N):
    if p[i] != i+1:
        diff += 1
print("YES" if diff == 0 or diff == 2 else "NO")
# Judge status: Accepted
k = int(input())

nums = []
def inc(num):
    if num > 3234566667:
        return None
    if num <= 3234566667:
      nums.append(num)

    end = str(num)[-1:]
    end_num = int(end)

    if end_num < 9:
        inc(num * 10 + end_num + 1)

    inc(num * 10 + end_num)

    if end_num > 0:
        inc(num * 10 + end_num - 1)

for i in range(1, 10):
    inc(i)

sort_nums = sorted(nums)
print(sorted(nums)[k - 1])
# Judge status: Accepted
import datetime
t = datetime.datetime.strptime("2019/04/30","%Y/%m/%d")
s = datetime.datetime.strptime(input(),"%Y/%m/%d")
print("Heisei") if t>=s else print("TBD")
# Judge status: Accepted
N, M = map(int,input().split())
f = []
for i in range(N):
  f.append(list(map(int,input().split())))
c = 0
for i in range(M):
  b = False
  for j in range(N):
    if not i+1 in f[j][1:]:
      b = True
      break
      
  if not b:
    c+=1
print(c)
# Judge status: Accepted
X = int(input())
done = False
num = X - 1

while not done:
    num += 1
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                break
        else:
            done = True

print(num)
# Judge status: Wrong Answer
s = input()

result = 'Yes'
j = int((len(s)-1)/2)
for i in range(int(j/2)):
    if(s[i] != s[j-i-1]):
        result = 'No'
        break

for i in range(j+1,j+int(j/2)):
    if(s[i] != s[j-i-1]):
        result = 'No'
        break

print(result)
# Judge status: Accepted
a, b, c = input().split()
print(a[0]+b[0]+c[0])
# Judge status: Accepted
n,k=map(int,input().split())
n=n%k



print(min(n,k-n))
# Judge status: Accepted
a,b = input().split()
num = int(a+b)
for i in range(1,1000):
    if i*i == num:
        print("Yes")
        exit()
print("No")
# Judge status: Wrong Answer
S = input()
if len(set(S)) == 1:
    print(S)
elif int(S[0] * 3) > int(S):
    print(S[0] * 3)
else:
    print(S[1] * 3)
# Judge status: Accepted
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
W = LI()
ans = math.inf
for i in range(n):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a<= b:
    print(a*c)
else:
    print(c*b +(a-b)*d)
# Judge status: Wrong Answer
n = int(input())
s = int(input())
x = int(n**0.5)+1
def dsum(x,t):
  ret = 0
  while x>0:
    ret += x%t
    x //= t
  return ret
if n == s:
  print(n+1)
  exit()
for i in range(2,x+1):
  if dsum(n,i) == s:
    print(i)
    exit()
for i in range(x,0,-1):
  if (n-(s-i))%i == 0:
    digit = (n-(s-i))//i
    if 0 < i < digit and 0 <= s-i < digit:
      print((n-(s-i))//i,i)
      exit()
print(-1)
# Judge status: Accepted
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(100000):
  if N<=K+i*(K-1) :
    print(i+1)
    exit()
# Judge status: Wrong Answer
char = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
print(char[char.index(input())])
# Judge status: Accepted
if int(''.join(input().split()))%4==0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
#!/usr/bin/env python3
import math
import sys
sys.setrecursionlimit(10**6)


n = int(input())
a = list(map(int, input().split()))

ans = 10**10

for i in a:
    tmp = 0
    while(i % 2 != 1):
        tmp += 1
        i = i//2
    # print(tmp)
    ans = min(ans, tmp)

print(ans)
# Judge status: Wrong Answer
s=input()
a=int(s[0:2])
b=int(s[2:4])
if 0<a<13:
  if 0<b<13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<b<13:
    print('YYMM')
  else:
    print('NA')
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split()]
n1 = 0
n2 = 0
n4 = 0

for a in A:
  if a&1:
    n1 += 1
  elif a%4==0:
    n4 += 1
  else:
    n2 += 1

 
bl = True
# n1 <= n4なら、141414と並べてあとは適当
if n1 > n4:
  #1414...141のときだけ
  if not(n1 == n4 + 1 and n2 == 0):
    bl = False

answer = 'Yes' if bl else 'No'
print(answer)
# Judge status: Accepted
import numpy as np
N = int(input())
A = np.array([int(input()) for _ in range(N)])
ans = 0
for i in range(N-1):
    d,m = divmod(A[i],2)
    ans += d
    if m == 1:
        if A[i+1] > 0:
            A[i+1] -= 1
            ans += 1

ans += A[-1]//2
print(ans)
# Judge status: Wrong Answer
a, b, c = map(int,input().split())
A = []
for i in range(1,b+1):
    mod = a*i % b
    if mod in A:break
    A.append(mod)

A.sort()
if len(A) >= 2:
    i = A[1]
else:
    i = 0

if i == 0 and c == 0:
    print('Yes')
    exit()
elif i == 0 and c != 0:
    print('No')
    exit()

if c % i == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
o = input()
e = input()
pas = ''
for i in range(len(e)):
  pas += o[i] + e[i]
if len(o) > len(e):
  pas += o[-1]
print(pas)
# Judge status: Accepted
N = int(input())
S = list(input())

bl = [0] * (N+1)    # 左に黒が何個あるか
wr = [0] * (N+1)    # 右に白が何個あるか
for i in range(N): bl[i+1] = bl[i] + (1 if S[i] == '#' else 0)
for i in range(N-1,-1,-1): wr[i] = wr[i+1] + (1 if S[i] == '.' else 0)

ans = N+1
for i in range(N+1): ans = min(ans, bl[i]+wr[i])
print(ans)
# Judge status: Accepted
n = int(input())
x_y = []
for _ in range(n):
  x_y.append([int(i) for i in input().split()])
import itertools
import math
ans = 0.0
for x_yi in itertools.permutations(x_y, n):
  sum_ = 0.0
  for i in range(n-1):
    sum_ += math.sqrt((x_yi[i][0] - x_yi[i+1][0]) ** 2 +
                      (x_yi[i][1] - x_yi[i+1][1]) ** 2)
  ans += sum_ / math.factorial(n)
print(ans)
# Judge status: Accepted
from collections import Counter

n = int(input())
A = Counter([int(i) for i in input().split()])

A = sorted(A.items(), key=lambda x: -x[0])

x = []
while len(x) < 2:
    for a, cnt in A:
        while cnt > 1 and len(x) < 2:
            x.append(a)
            cnt -= 2
    else:
        break

if len(x) < 2:
    print(0)
else:
    print(x[0] * x[1])
# Judge status: Accepted
a = int(input())
print(a + a * a + a * a * a)
# Judge status: Wrong Answer
a = int(input())
b=list(map(int,input().split()))
c=b
c.sort()
d=[]
print(c)
for i in range(a):
    for j in range(a):
        b[i],b[j]=b[j],b[i]
        print(b)
        if b==c:
            d.append(b)
        else:
            continue
if len(d)!=0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
s = input()
s = list(s)
s[3] = '8'
s = "".join(s)
print(s)
# Judge status: Accepted
a,b=map(int,input().split())
n=b-a
print(n*(n+1)//2-b)
# Judge status: Accepted
import numpy as np
n, m, x = map(int, input().split())
l = []
for _ in range(n):
  l.append(list(map(int, input().split())))

l = np.array(l)
val = 9999999
for i in range(2 ** n):
  curr = np.array([0 for _ in range(m+1)])
  for j in range(n):
    if ((i >> j) & 1):
      curr += l[j]
  flag = True
  for k in range(m):
    if curr[k+1] < x:
      flag = False
  if flag:
    if val > curr[0]:
      val = curr[0]
      
if val == 9999999:
  print("-1")
else:
  print(val)
# Judge status: Accepted
import math
n,x,t=map(int,input().split())

y = t * int(math.ceil(n/x))
print(y)
# Judge status: Accepted
def main():
    a,b,x = (int(x) for x in input().split())
    print('YES' if b>=(x-a) and a<=x else 'NO')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
x,y = map(int,input().split())
if ((x >= 0 and y >= 0) or (x < 0 and y < 0)) and x < y:
    print(y-x)
elif (x >= 0 and y >= 0) and y < x:
    print(abs(x-y)+2)
elif (x < 0 and y < 0) and y < x:
    print(abs(x-y)+2)
elif x == -y:
    print(1)
else:
    print(abs(x-y)+1)
# Judge status: Wrong Answer
n,a,b=map(int, input().split())
ans = 0
for i in range(n):
  d = i
  c = 0
  while d >0:
    c += (d%10)
    d = d // 10
  if a <= c <= b:
    ans += 1
print(ans)
# Judge status: Accepted
n,k,*h=map(int,open(0).read().split())

INF=float("inf")
dp=[INF]*(n)
dp[0]=0

for i in range(n):
    for j in range(1,k+1):
        # try:
        #     dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        # except:
        #     pass

        if not i-j<0:
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))


print(dp[-1])
# Judge status: Wrong Answer
n, k = map(int, input().split())

mod = 10 ** 9 + 7

def comb(n, k):
    res = 1
    for i in range(n - k + 1, n + 1):
        res = res * i % mod
    for i in range(1, k + 1):
        res = res * pow(i, mod - 2, mod) % mod
    return res

calc = comb(n + 1, k)
ans = 0
ans += calc

for i in range(k + 1, n + 1):
    calc *= n + 2 - i
    calc //= i
    ans += calc

if k == n + 1:
    ans = 1
    
print(ans % mod)