peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   if(N == K): return 1
   if(K == 2): return N - 1
   total = K *ceil(N/K) - (ceil(N/K) - 1)
   ans = ceil(N/K)
   # print(total,ans)
   if(total < N):
      ans += 1
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()
# Judge status: Wrong Answer
K,N=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N-2):
    if (A[i+2]-A[i+1])>=(A[i+1]-A[i]):
        l=A[i+2]-A[i+1]
if (20-A[N-1]+A[0])>=l:
    l=20-A[N-1]+A[0]
print(K-l)
# Judge status: Wrong Answer
a, b, k = list(map(int, input().split()))
l0 = []
l1 = []
for i in range(1, a+1):
    if a % i == 0:
        l0.append(i)
        for j in l0:
            if b % j == 0:
                l1.append(j)
s = set(l1)
ll = list(s)
print(ll[len(ll)-k])
# Judge status: Wrong Answer
n = int(input())
c = input()

w = [0]*(n+1)
r = [0]*(n+1)
for i in range(0,n):
  w[i+1] = w[i]
  r[n-i-1] = r[n-i]
  if c[i]=='W':
    w[i+1] += 1
  if c[n-i-1]=='R':
    r[n-i-1] += 1

print([w[i]+r[i]-min(w[i],r[i]) for i in range(0,n+1)])
# Judge status: Accepted
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [0] * N
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)
# Judge status: Accepted
import sys
L = int(input())
print((L / 3) ** 3)
# Judge status: Wrong Answer
a, b, c, d = input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
def m():
    if a<=b and c<=d:
        max=a*b+c*d
        print(max)
    else:
        print("plese press again")
m()
# Judge status: Accepted
a1=input()
a2=[i for i in a1.split()]
x,y=float(a2[0]),float(a2[1])
v,v1=x.is_integer(),y.is_integer()
if 1<=x<=20 and 1<=y<=20 and v==v1==True:
    if 1<=x<=9 and 1<=y<=9:
        print(int(x*y))
    else:
        print('-1')
# Judge status: Accepted
A,B,K=map(int,input().split())
ans=0
n=100
while True:
    if A%n==0 and B%n==0:
        ans+=1
        if ans==K:
            print(n)
            exit()
    n-=1
# Judge status: Accepted
n=int(input())


sum_data=n+n*n+n*n*n
print(sum_data)
# Judge status: Accepted
n = int(input())
lst = list(map(int, input().split()))
res = 0
for i in range(1, n - 1):
  if lst[i] == sorted([lst[i - 1], lst[i], lst[i + 1]])[1]:
    res += 1
print(res)
# Judge status: Accepted
N = int(input())
p = list(map(int, input().split()))

res = 0
for i in range(len(p) - 1):
    if i + 1 != p[i]:
        continue

    res += 1
    tmp = p[i]
    p[i] = p[i+1]
    p[i+1] = tmp

if N == p[N-1]:
    res += 1

print(res)
# Judge status: Accepted
a,b,c=input().split()
print('A'+b[0]+'C')
# Judge status: Accepted
x,y=map(int,input().split());print(' YNeos'[len(set([2 if i in [2] else 1 if i in [4,6,9,11] else 0 for i in [x,y]]))::2])
# Judge status: Accepted
X = int(input())

CNT = 500

for a in range(-CNT, CNT):
    for b in range(-CNT, CNT):
        if X == a ** 5 - b ** 5:
            print(a, b)
            exit()
# Judge status: Wrong Answer
s = str(input())
Acount = 0
Zcount = 0
for i in range (len(s)):
    if s[i] == 'A':
        Acount = i
        break

for j in range (len(s)):
    if s[j] == 'Z':
        Zcount = j

print(j - i +1)
# Judge status: Accepted
n = int(input())
ans = 0
prev = 0
for _ in range(n):
    a = int(input())
    tmp_ans = (a + prev) // 2
    ans += tmp_ans
    if tmp_ans == 0:
        prev = a % 2
    else:
        prev = (a + prev) % 2
print(ans)
# Judge status: Accepted
N = int(input());K = int(input());X = int(input());Y = int(input())
print(K*X + (N-K)*Y if N > K else N*X)
# Judge status: Wrong Answer
import sys
x,n = map(int,input().split())
a = list(map(int,input().split()))
if x in a:
    s = 0; t = 0
    for i in range(x+1,100):
        if i not in a:
            s = i
            sys.exit()
    for j in reversed(range(x-1,-100)):
        if i not in a:
            t = j
            sys.exit()
    if abs(x-s) < abs(x-t):
        print(s)
    elif abs(x-s) > abs(x-t):
        print(t)
else:
    print(x)
# Judge status: Accepted
n = int(input())
if n >= 1000:
  print('ABD')
else:
  print('ABC')
# Judge status: Wrong Answer
N=int(input())
ans=[]
if N==1:
    print(1)
    exit()
if N==4:
    print(1)
    print(3)
    exit()
count=0
for i in range(1,N+1):
    count+=i
    ans.append(i)
    if count>=N:
        break
if count==N:
    for i in range(len(ans)):
        print(ans[i])
    exit()
ans=[]
if N%2==0:
    ans.append(1)
    ans.append(N//2-1)
    ans.append(N//2)
else:
    ans.append(N//2)
    ans.append(N//2+1)
for i in range(len(ans)):
    print(ans[i])
# Judge status: Wrong Answer
import math
a,b,c = [int(x) for x in input().split()]
k = int(input())
a1,b1,c1 = math.log2(a),math.log2(b),math.log2(c)
k1,k2 = 0,0
if b1<a1:
    k1 = math.floor(a1-b1+1)
    b1 = b1+k1
if c1<b1:
    k2 = math.floor(b1-c1+1)
if k1+k2<=k:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
X = int(input())
ans = 100
count = 0

while ans <= X:
    count += 1
    ans = ans * 1.01

print(count)
# Judge status: Wrong Answer
import math
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
a_max=max(a)
b=list(filter(lambda x: x>a_max, b))
ans=len(b) + math.ceil((h-sum(b))/a_max)
print(ans)
# Judge status: Accepted
n = int(input())
s = list(map(str,input()))
left = 0
right = 0
for i in range(n):
    if s[i]==".":
        right += 1
ans = right
if s[0]==".":
    right -= 1
for j in range(1,n):
    if s[j-1]=="#":
        left += 1
    if s[j]==".":
        right -= 1
    ans = min([ans,left+right])
if s[n-1]=="#":
    left += 1
ans = min([ans,left])
print(ans)
# Judge status: Wrong Answer
def check_service(service):
    no_service = ['AAA', 'BBB']
    if service in no_service:
        print("No")
    print("Yes")
# Judge status: Accepted
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    *line, k = [int(sys.stdin.readline().rstrip()) for _ in range(6)]
    print(':(' if max(line) - min(line) > k else 'Yay!')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s=input()
a=["SUN","MON","TUE","WED","THU","FRI","SAT"]
count=0
for i in range(7):
    if s==a[0]:
        break
    count+=1
print(7-count)
# Judge status: Wrong Answer
A,B,C,K = map(int,input().split())
for i in range(min(K, 100000)):
    A,B,C = B+C,C+A,A+B
    if A - B > 10**18 or A - B < -10**18:
        print("Unfair")
        exit()
print(A-B)
# Judge status: Wrong Answer
N=int(input())
t=0
x=0
y=0
for i in range(N):
    t_next,x_next,y_next=map(int,input().split())
    zikan=t_next - t
    kyori=abs(x_next-x)+abs(y_next-y)
    if kyori>zikan or (zikan-kyori)%2==1:
        print('NO')
        exit(0)
    t,x,y=t_next,x_next,y_next
print('YES')
# Judge status: Wrong Answer
import math

total = list(map(lambda x: int(x), input().split()))
possible = list({0,1,2,3,4,5,6,7,8,9} - set(list(map(lambda x: int(x), input().split()))))
yen = [int(d) for d in str(total[0])]




for index, i in enumerate(yen):
    if i not in possible:
        for j in possible:
            if j > i:
                yen[index] = j

print(int(''.join(map(str, yen))))
# Judge status: Accepted
n,T= map(int,input().split())
min = 1001
for i in range(n):
    c,t = map(int,input().split())
    if T >= t and min > c:
        min = c
if min > 1000:
    print('TLE')
else:
    print(min)
# Judge status: Wrong Answer
#C
n, m = map(int, input().split())
l = []
r = []
for _ in range(m):
    tmp=list(map(int,input().split()))
    l.append(tmp[0])
    r.append(tmp[1])
lmax = max(l)
rmin = min(r)
print(rmin - lmax + 1)
# Judge status: Accepted
N = int(input())
v = list(map(int, input().split()))
v.sort(reverse=True)
while len(v) > 1:
  num1 = v.pop()
  num2 = v.pop()
  result = (num1 + num2) / 2
  v.append(result)
  v.sort(reverse=True)
print(v[0])
# Judge status: Accepted
A,B = map(int,input().split())
if A>B:
    A,B = B,A
if (B-A)%2==0:
    print((B+A)//2)
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
A, B= map(int, input().split())

if A - B == 0:
    print("Draw")
elif A == 1 or B == 1:
    if A - B < 0:
        print("Alice")
    else:
        print("Bob")
else:
    if A - B < 0:
        print("Bob")
    else:
        print("Alice")
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
x=[0]*35
b=[[] for i in range(len(A))]
for i,a in enumerate(A):
  j=0
  while a>0:
    _=a%2
    b[i].append(_)
    x[j]=(x[j]+_)%2
    a=a>>1
    j+=1
ans=[]
for i in range(N):
  j=0
  _=0
  while j<len(b[i]):
    _+=abs(x[j]-b[i][j])*2**j
    j+=1
  ans.append(_)
print(*ans)
# Judge status: Accepted
s = set(input())
a = set("abcdefghijklmnopqrstuvwxyz")
d = a - s
if d:
    print(sorted(d)[0])
else:
    print("None")
# Judge status: Accepted
*a,=map(int,open(0).read().split());print('YNeos'[all(t-set(map(a.index,a[10:]))for t in({0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}))::2])
# Judge status: Wrong Answer
N=int(input())
l=list(map(int,input().split()))
a=N//2
ans=l[a]-l[a-1]
print(ans)
# Judge status: Wrong Answer
a=input()
b=input()

kotae=0
for i in range(len(a)):
    if a[i]!=b[i]:
        kotae+=1
# Judge status: Accepted
def f(words):
	seen = set([words[0]])
	p = words[0]
	for w in words[1:]:
		if w in seen or p[-1] != w[0]: return False
		p = w
		seen.add(w)
	return True

print 'Yes' if f([raw_input() for _ in range(int(raw_input()))]) else 'No'
# Judge status: Accepted
x,y,z = map(int,input().split())
x -= z
print(x // (y+z))
# Judge status: Wrong Answer
a = input()
if "join(sorted(a))"=="abc":
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n, x = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
a = 0
b = 0
for i in range(n):
  b += 1
  if a > x:
    break
  a += l[i]
    
print(b)
# Judge status: Accepted
S = input()
T = input()

result = float('inf')
for i in range(len(S) - len(T) + 1):
    count = sum(x != y for x, y in zip(S[i:i+len(T)], T))
    if count < result:
        result = count
print(result)
# Judge status: Accepted
import heapq
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    ans = 0
    d = defaultdict(list)
    for _ in range(N):
        A, B = map(int, input().split())
        d[A].append(-B)
    cand = []
    heapq.heapify(cand)
    for day in range(M-1,-1,-1):
        diff = M - day
        for money in d[diff]:
            heapq.heappush(cand, money)
        if cand:
            ans -= heapq.heappop(cand)

    print(ans)



if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())

t = []
for i in range(1,n+1):
  s,p = tuple(input().split())
  p = int(p)
  t.append((s,p,i))
t = sorted(t,key = lambda a:a[1],reverse=True)
t = sorted(t,key = lambda a:a[0])

for _,_,i in t:
  print(i)
# Judge status: Accepted
a, b = map(int, input().split())

if a == b:
  print(a+b)
elif a > b:
  print(a+a-1)
else:
  print(b+b-1)
# Judge status: Wrong Answer
s = input()
t = 0
for i in range(3):
    if s[i] == 1:
        t = t + 1
print(t)
# Judge status: Accepted
List = ['Sunny', 'Cloudy', 'Rainy']
S = input()
print(List[(List.index(S) + 1) % 3])
# Judge status: Accepted
N = str(input())
for i in range(2):
  if N[i] == N[i+1] and N[i+1] == N[i+2]:
    print("Yes")
    exit()
print("No")
# Judge status: Accepted
import sys
s = str(input())
n = int(input())
i = 0
while True:
    if int(s[i]) == 1:
        if (n-1) == i:
            print("1")
            sys.exit()
        else:
            i += 1
    else:
        print(s[i])
        sys.exit()
# Judge status: Accepted
N = int(input())

count = dict.fromkeys(["AC", "WA", "TLE", "RE"], 0)

for idx in range(N):
  S = input()
  count[S] += 1

for k, v in count.items():
  print(k, "x", v)
# Judge status: Accepted
C=[list(map(int,input().split())) for i in range(3)]
Bs=[C[0][i] for i in range(3)]
As=[0,C[1][0]-Bs[0],C[2][0]-Bs[0]]
if all(As[i]+Bs[j]==C[i][j] for i in range(3) for j in range(3)):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    n, a, b = map(int, input().split())
    q, mod = divmod(n, (a+b))
    x = mod if mod < a else a
    print(q*a+x)

if __name__ == "__main__":
    main()
# Judge status: Accepted
a = input()
b = len(a)
if a == a[::-1]:
  if a[:(b-1)//2] == a[:(b-1)//2][::-1] and a[(b+1)//2:] == a[(b+1)//2:][::-1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")
# Judge status: Accepted
X=input()

for i in range(len(X)):
    if X[-7:] == "dreamer":
        X = X[:-7]
    elif X[-6:] == "eraser":
        X = X[:-6]
    elif X[-5:] == "dream":
            X = X[:-5]
    elif X[-5:] == "erase":
        X = X[:-5]

print("YES" if X=="" else "NO")
# Judge status: Accepted
s = input()
if len(set(s))==2:
    if len(s.replace(s[0], ''))==2:
        print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()

if (s[0] == s[2]) and (s[0] != s[1]):
    print('Yes')
elif (s[1] == s[2]) and (s[0] != s[2]):
    print('Yes')
elif (s[0] == s[1]) and (s[0] != s[2]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import numpy as np
from collections import Counter


n = int(input())
A = list(map(int, input().split()))
A.sort()
is_divisible = np.zeros(10**6+1, dtype=np.int64)


def update(num):
    nums = np.arange(num, 10**6+1, num)
    is_divisible[nums] = True

counter = Counter(A)
ans = 0
for a, count in counter.items():
    if count == 1 and not is_divisible[a]:
        ans += 1
        
    update(a)

print(ans)
# Judge status: Wrong Answer
n,k,q = map(int, input().split())

score = [-q]*n

for i in range(q):
	dat = int(input())-1
	score[dat] = score[dat] + k + 1

for i in range(n):
	if score[i] > 0:
		print("Yes")
	else:
		print("No")
# Judge status: Wrong Answer
n = int(input())
paper = dict()
for i in range(n):
    a = int(input())
    if a not in paper:
        paper[a] = 1
    else:
        paper[a] = 0

res = 0
for value in paper.values():
    if value == 1:
        res += 1
print(res)
# Judge status: Accepted
A,B=map(int, input().split())
count=0
tap = 1
while(tap < B):
  tap += A-1
  count += 1
 
print(count)
# Judge status: Accepted
A,B=map(int,input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")
# Judge status: Accepted
from collections import Counter

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]
sc = Counter(s)
ss = set(s)
ans = 0

for k in ss:
    ans += (sc[k]*(sc[k]-1))//2

print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
if a==b: print(a*2)
else: print(max(a, b)*2-1)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = dif = 0
for i in range(n+1):
    cnt += min(dif,a[i])
    if i!=n:
        a[i] -= min(dif,a[i])
        cnt += min(a[i],b[i])
        dif = max(0,b[i]-a[i])
print(cnt)
# Judge status: Accepted
import heapq
 
n,m = map(int,input().split())
ab=[[] for _ in range(m)]
for i in range(n):
    a,b=map(int,input().split())
    if a < m+1:
        ab[a-1].append(-b)
 
h=[]
ans=0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(h,j)
    if len(h)==0:
        continue
    ans+=heapq.heappop(h)*(-1)
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
k = 0

while all(i//2 == 0 for i in A):
    A = [i/2 for i in A]
    k += 1

print(k)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
a=[]
b=[]
for i in A:
    if i%2==0:
        a.append(i)
for n in a:
    if n%3==0 or n%5==0:
        b.append(n)
if len(a)==len(b):
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import math

S1 = 1

r = input('radius = ')
R = int(r)
S2 = R ** 2

result = S2 / S1
print(math.floor(result))
# Judge status: Wrong Answer
import itertools
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(min(k,34)):
  
  imos=[0]*(n+1)
  for j in range(n):
    imos[max(j-a[j],0)]+=1
    imos[min(j+a[j]+1,n)]-=1
  a=list(itertools.accumulate(imos))
  
  if a[:n]==[n]*n:
    break
print(*a[:n])
# Judge status: Accepted
N = int(input())
MOD = 10**9 + 7

ans = 1
for i in range(1, N + 1):
    ans = (ans * i) % MOD

print(ans)
# Judge status: Accepted
import collections
N=int(input())
ss=['' for i in range(N)]

for i in range(N):
    ss[i]=''.join(sorted(str(input())))

cc=collections.Counter(ss)
ans=0
values, counts = zip(*cc.most_common())
counts=list(counts)

for i in range(len(counts)):
    if counts[i]==1:
        break
    else:
        ans+=counts[i]*(counts[i]-1)/2

print(int(ans))
# Judge status: Wrong Answer
N,K = map(int,input().split())
A = [int(a) for a in input().split()]

n = 0

for i in range(K+1,N):
    if A[i] > A[n] :
        print("Yes")
    else:
        print("No")
    n+=1
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=0
y=a[0]
for i in range(n):
  y=min(y,a[i])
  y+=a[i+1]
  x+=min(y,b[i])
  y=max(y-b[i],0)
print(x)
# Judge status: Accepted
N = int(input())
list0 = {}
for i in range(N):
  x = input()
  if x in list0:
    list0[x] = list0[x] + 1
  else:
    list0[x] = 1
m = max(list0.values())
k_m = [key for key in list0 if list0[key] == m]
k_m.sort()
for i in range(len(k_m)):
  print(k_m[i])
# Judge status: Accepted
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    l = reduce(lcm, a)
    c = 1
    while a[0] % (2 * c) == 0:
        c *= 2
    f = (a[0] // c) % 2
    for _a in a:
        if _a % c > 0 or (_a // c) % 2 != f:
            return "0"
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
yen = 1000
stock = 0
an = []
i = 0
while 1:
    while i <= n - 2 and a[i] >= a[i+1]:
        i += 1
    if i == n - 1:
        print(yen)
        exit()
    stock, yen = divmod(yen, a[i])
    while i <= n-2 and a[i] <= a[i+1]:
        i += 1
    stock, yen = 0, yen + a[i] * stock
# Judge status: Accepted
from functools import reduce
from fractions import gcd

#最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

N = int(input())
A = [int(a) for a in input().split()]

print(gcd_list(A))
# Judge status: Wrong Answer
n = int(input())
s = input()
ans = ""
for i in s:
  t = ord(i)
  if t >= 90 - n:
    t = 65 + t - (90 - n)
  else:
    t += n
  ans += chr(t)
print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    ans = 0
    for a in range(1,n):
        ans += -(-n//a) - 1
    print(ans)
        

if __name__=='__main__':
    main()
# Judge status: Accepted
n=int(input())
happy=[[] for i in range(n)]
for i in range(n):
  happy[i]=list(map(int,input().split()))
dp=[[0,0,0] for i in range(n)]
dp[0]=[happy[0][0],happy[0][1],happy[0][2]]
for i in range(1,n):
  #print('i is ',i)
  for j in range(3):#i日目に幸福jを選んだ場合の幸福最大をdp[i][j]とする。
    x=[]
    for k in range(3):
      if k!=j:
        x.append(dp[i-1][k])
    dp[i][j]=max(x)+happy[i][j]
    #print(j,x)
print(max(dp[n-1]))
# Judge status: Accepted
string = input()

if(len(string) % 2 != 0):
    print("No")
    exit()

for i in range(0, 10, 2):
    if len(string) > i:
        if string[i] != 'h' or string[i + 1] != 'i':
            print("No")
            exit()

print("Yes")
# Judge status: Accepted
def answercount(n , s):

    not10min = 101
    for i in range(n):
        if int(s[i]) % 10 != 0:
            not10min = min(not10min , s[i])

    if not10min == 101:
        return 0

    if int(sum(s)) % 10 == 0:
        return (int(sum(s)) - not10min)

    return int(sum(s))

def main():
    n = int(input())
    s = [int(input()) for i in range(n)]
    print(answercount(n , s))

if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())
A=[0]*N
B=[0]*N

for i in range(N):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b

A=A[::-1]
B=B[::-1]

K=0
for i in range(N):
    if (A[i]+K)%B[i]:
        L=B[i]-((A[i]+K)%B[i])
        K+=L
print(K)
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    for i in range(0,N+1,7):
        if (N-i)%4==0:
            print('Yes')
            break
    else:
        print('No')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
x = input()

if x == '7' or '5' or '3':
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)

i=0
arr=[]
while i<n-1:
    if a[i]==a[i+1]:
        arr.append(a[i])
        i+=2
    else:
        i+=1
    if len(arr)==2:
        print(arr[0]*arr[1])
        exit()
print(0)
# Judge status: Accepted
import sys

X = int(input())
for i in range(-500,500):
    for j in range(-500,500):
        if pow(i,5) - pow(j,5) == X:
            print(i,j)
            sys.exit()
# Judge status: Accepted
s = input()
print('Yes' if len(set(s)) == 2 and s.count(s[0]) == 2 else 'No')
# Judge status: Wrong Answer
s = input()

l=[]
for i in range(len(s)):
  l.append(s[i])
           
x = set(l)
           
if len(x) == len(s):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
S = input()
T = input()

if S == T[:-1]:
	print("YES")
else:
	print("NO")
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))

c=1

for i in range(n-k):
  if a[k+i] > a[i]:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
n = int(input())

def func(x):
    a = x%10
    b = 0
    while x:
        b = x
        x //= 10
    return (a,b)

freq = {}

for i in range(1, n+1):
    p = func(i)
    freq[p] = freq.get(p, 0) + 1

ans = 0

for i in range(1, n+1):
    p = func(i)
    ans += freq.get((p[1],p[0]), 0)
    
print(ans)
# Judge status: Wrong Answer
import math
 
a, b, c = map(int,input().split())
 
if a+b+(2*math.sqrt(a*b)) < c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
X = input()
cnt = 0
res = 0
for i in X:
  if i == 'S':
    cnt += 1
  else:
    if cnt > 0:
      cnt -= 1
    else:
      res += 1
print(cnt + res)
# Judge status: Accepted
N=int(input())
A=int(input())
Q=N%500
if Q<=A:
    print("Yes")
else :
    print("No")
# Judge status: Accepted
n=int(input())
a=[int(input())*(-1) for _ in range(n)]
inf=10**10
l=[inf]*n
import bisect
for i in range(n):
	r=bisect.bisect_right(l,a[i])
	l[r]=a[i]
cnt=0
for i in range(n):
	if l[i]!=inf:
		cnt+=1
	else:
		break
print(cnt)
# Judge status: Accepted
K, X = map(int, input().split())
for i in range(X-K+1, X+K):
  print(i, end=" ")
# Judge status: Accepted
a, b = map(int, input().split())
if a*b < 0:
  print("Zero")
elif a > 0:
  print("Positive")
elif a == 0 or b == 0:
  print("Zero")
else:
  if (b-a)%2:
    print("Positive")
  else:
    print("Negative")
# Judge status: Accepted
from bisect import bisect_left, bisect_right
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect_left(A, b)
    c = bisect_right(C, b)
    ans += a * (N-c)
print(ans)
# Judge status: Accepted
n = int(input())
if n ==0:
    print(0)
else:
    res = []
    while n != 0:
        if n % 2 == 1:
            res.append("1")
        else:
            res.append("0")
        n = (n-n%2) // -2
    res = res[::-1]
    print("".join(res))
# Judge status: Accepted
from collections import Counter
 
n = int(input())
d = list(map(int, input().split()))
mod = 998244353
 
c = Counter(d)
 
if d[0] != 0 or c[0] != 1:
    print(0)
    exit()
 
ans = 1
for i in range(1, max(d)+1):
    if i not in c:
        print(0)
        exit()
    ans *= pow(c[i-1], c[i], mod)
 
print(ans % mod)