peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n = int(input())

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

if is_prime(n):
    print(1)
    exit()

cnt = 0
flag = 10*110
for z in range(2,10**12):
    if n % flag == 0:
        continue
    if n % z == 0:
        n = n // z
        cnt += 1
    else:
        flag +=z

    if n == 1 or is_prime(n) == True:
        print(cnt)
        exit()
# Judge status: Wrong Answer
input_str = input().split()
k = int(input_str[0])
s = int(input_str[1])

count = 0
for x in range(k+1):
  for y in range(k+1-x):
      for z in range(k+1-x-y):
        if x+y+z == s:
          count += 1
print(count)
# Judge status: Accepted
s = input()
l = ["a", "i", "u", "e", "o"]
print("vowel" if s in l else "consonant")
# Judge status: Accepted
X, Y, Z = map(int, input().split())
ans = 0

for i in range(1, X):
    if i*Y+(i+1)*Z <= X:
        ans = i
    else:
        break
print(ans)
# Judge status: Wrong Answer
s = input()

a = 'No'

if s[0] == s[1]:
  if s[2] == s[3]:
    a = 'Yes'
if s[0] == s[2]:
  if s[1] == s[3]:
    a = 'Yes'
if s[0] == s[3]:
  if s[1] == s[2]:
    a = 'Yes'
if s[1] == s[2]:
  if s[0] == s[3]:
    a = 'Yes'
if s[1] == s[3]:
  if s[0] == s[2]:
    a = 'Yes'
if s[2] == s[3]:
  if s[0] == s[1]:
    a = 'Yes'
    
print(a)
# Judge status: Accepted
from bisect import bisect_left
from collections import deque
N = int(input())
a = int(input())
ls = deque([a])
for i in range(N-1):
  c = int(input())
  ind = bisect_left(ls,c)
  if ind==0:
    ls.appendleft(c)
    continue
  ls[ind-1] = c
print(len(ls))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
sum_A = sum(A)
x, y = 0, 0
ans = sum_A
for i in range(N-1):
  x += A[i]
  y = sum_A - x
  ans = min(ans, abs(x-y))
print(ans)
# Judge status: Wrong Answer
import itertools
n,m=map(int,input().split())
ab= [list(map(int,input().split())) for _ in range(m)]
ab=list(itertools.chain.from_iterable(ab))
k=len(set(ab))
for i in range(1,k+1):
    print(ab.count(i))
# Judge status: Wrong Answer
N, M, X, Y = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))

flag = True

if y[0] < x[-1]:
    flag = False

if flag:
    if X in y:
        flag = False
    if Y in x:
        flag = False

if flag:
    print("No War")
else:
    print("War")
# Judge status: Accepted
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
c = 0
for a, b in D:
    if a == b: c += 1
    else: c = 0
    if c >= 3:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
S = input()
T = input()
result=0
for i in range(len(S)):
    if S[i] != T[i]:
        result += 1
print(result)
# Judge status: Accepted
n=int(input())
s=input()
if n%2 != 0:
    print('No')
elif s[:n//2] == s[n//2:]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
res=1
mod=10*9+7
for i in range(1,n+1):
  res=res*i%mod
print(res)
# Judge status: Accepted
#"a" 97 "z" 122
s = list(ord(i) for i in input())
k = int(input())

for i in range(len(s)-1):
  if s[i] == ord("a"): continue
  t = ord("z")+1-s[i]
  if k >= t:
    s[i] = 97
    k -= t
if k > 0:
  k %= 26
  s[-1] += k
  if s[-1] > ord("z"):
    s[-1] -= 26
print("".join(list(map(chr, s))))
# Judge status: Accepted
x = [1,2,3]
A = int(input())
B = int(input())
x.remove(A)
x.remove(B)
print(x[0])
# Judge status: Accepted
n,m = map(int,input().split())

C={}
S1=[]
for i in range(n):
    a,b = map(int,input().split())
    S1.append(a)
    if a in C:
        C[a]+=b
    else:
        C[a]=b
S=list(set(S1))
S.sort()

ans=0
for s in S:
    # print(S,C,ans)
    if m<C[s] :
        ans+=m*s
        break
    else:
        ans+=C[s]*s
        m-=C[s]

print(ans)
# Judge status: Accepted
def main():
    paramX = int(input())
    size = 200
    for a in range(size * -1, size):
        for b in range(size * -1, size):
            if pow(a, 5) - pow(b, 5) == paramX:
                print(a, b)
                return
    print(1, 1)
main()
# Judge status: Wrong Answer
from math import pi, tan
EPS = 0.0000000001

def f(a, b, theta):
    if theta >= pi * 0.5:
        return 0.0
    elif tan(theta) >= b / a:
        return b**2 * 0.5 / tan(theta)
    else:
        return a**2 * b - a**2 *b * 0.5 * tan(theta)

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

l = 0
r = pi * 0.5
while r - l >= EPS:
    mid = (l + r) * 0.5
    if f(a, b, mid) >= x:
        l = mid
    else:
        r = mid

print("{:.10f}".format(l / pi * 180))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

money = 1000
stock = 0
leave_max = max(a)

for i in range(n):
    if i == n-1:
        money += a[i] * stock
        break

    leave_max = max(a[i+1:])

    if a[i] >= a[i+1]:
        money += a[i] * stock
        stock = 0
        if a[i] > leave_max:
            break
        else:
            continue

    elif a[i] < a[i+1]:
        stock = money // a[i]
        money -= stock * a[i]

print(money)
# Judge status: Wrong Answer
x = int(input())

if x == 1:
    print("1")
    exit()


def func(p):
    q = 1
    while q <= x:
        q *= p
    return q / p


z = []
a = 2

while a <= x ** 0.5:
    z.append(func(a))
    a += 1

print(max(z))
# Judge status: Accepted
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x:(x[0]))
c = 0
ans = 0
for i in a:
    if c + i[1] < m:
        c += i[1]
        ans += i[0]*i[1]
    else:
        for j in range(i[1]):
                c += 1
                ans += i[0]
                if c >=m:
                    break
        break
print(ans)
# Judge status: Accepted
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
  A -= 1
elif U == T:
  B -= 1

print(A, B)
# Judge status: Wrong Answer
n = int(input())

m = int(n ** 0.5)
lst = [1] * (m + 1)
if n == 1:
  print(0)
else:
  count = 0
  num = n
  for i in range(2, m + 1):
    if lst[i] == 0:
      continue
    for j in range(i, m + 1, i):
      lst[j] = 0
      if num % j == 0:
        num /= j
        count += 1
      if num % j == num:
        break
    if num == 1:
      break
  if count == 0:
    count += 1
  print(count)
# Judge status: Wrong Answer
d,t,s=map(int,input().split())
if t*s>=d:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
S = input()
lenS = len(S)
count = [0] * 2019
count[0] = 1
num = 0
d = 1
for i in range(lenS):
    num += int(S[lenS - i - 1]) * d
    count[num%2019] += 1
    d *= 10
    d %= 2019
ans = 0
for i in count:
    ans += i*(i-1)//2
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
l=[0]*n
l1=[0]*n
day=0
K=0
for i in range(n):
    a,b=map(int,input().split())
    l[i]=a
    l1[i]=b
l2=sorted(l1,reverse=True)
for j in l2:
    if l[l1.index(j)]<=m-day:
        K+=j
    day+=1
print(K)
# 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
s = int(input())
p = 10 ** 9
xp = s % p
yp = s // p
x = p - xp
y = yp + 1

if s != 10 ** 18:
    print(0,0,p,1,x,y)
else:
    print(0,0,p,0,0,p)
# Judge status: Wrong Answer
import scipy.misc
N,P=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
odd = 0
even = 0
for i in A:
    if i%2 !=0:
        odd += 1
    else:
        even += 1

ans = 0
if P ==1:
    for i in range(1,odd+1,2):
        ans += scipy.misc.comb(odd,i)
else:
    for i in range(0,odd+1,2):
        ans += scipy.misc.comb(odd,i)
ans = ans*(2**even)
print(int(-(-1*ans//1)))
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))

a = arr[0]

for i in range(1, n):
    a ^= arr[i]

ans = []
for i in range(n):
    ans.append(a ^ arr[i])
    
print(*ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
ans = []
def bfs(s,tmp):
    if len(s)==n:
        ans.append(s)
        return
    for i in range(ord('a'),ord('a')+tmp+1):
        if i==ord('a')+tmp:
            bfs(s+chr(i),tmp+1)
        else:
            bfs(s+chr(i),tmp)
bfs('a',1)
print(*ans,sep='\n')
# Judge status: Accepted
n,k = map(int,input().split(" "))

sum = 0
for i in range(k,n+2):
    maxsum = (2*n-i+1)*i/2
    minsum = (i-1)*i/2

    num = maxsum-minsum +1
    sum += num
    sum = sum % (10**9+7)

print(int(sum))
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    x,y=map(int,input().split())
    print(x if x%y!=0 else -1)
    
resolve()
# Judge status: Accepted
from fractions import gcd
a, b, c, d = list(map(int, input().split()))

c_cnt = b // c  - (a-1) // c
d_cnt = b // d  - (a-1) // d

lcm = c * d // gcd(c, d)
lcm_cnt = b // lcm  - (a-1) // lcm

print((b - a + 1) - (c_cnt + d_cnt - lcm_cnt))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
t=(len(a)-2)//2
ans=a[0]
if (len(a)-2)%2==0:
  for i in range(1,t+1):
    ans+=a[i]*2
else:
  ans=ans+a[t+1]
  for i in range(1,t+1):
    ans+=a[i]*2
print(ans)
# Judge status: Wrong Answer
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
A = LI()

A.sort()
alice = 0
bob = 0
flag = 0
for i in A:
    if flag % 2 == 0:
        alice += i
    else:
        bob += i
    flag += 1
print(alice-bob)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

cnt = {}
for a in A:
    if a not in cnt:
        cnt[a] = 1
    else:
        cnt[a] += 1

A = [[k, v] for k, v in cnt.items()]
A.sort(reverse=True)

h = 0
w = 0
for k, v in A:
    if v >= 4 and h == 0:
        h = k
        w = k
        break
    elif v >= 2 and h > 0:
        w = k
        break
    elif v >= 2 and h == 0:
        h = k

print(h * w)
# Judge status: Accepted
a,b=map(int,input().split())
def g(x,y):
  while y: x,y=y,x%y
  return x
print(a*b//g(a,b))
# Judge status: Accepted
import sys
input = sys.stdin.readline
"""
N,X=map(int,input().split())
vA=list(map(int,input().split()))
vA.sort()
"""

S=input().rstrip()
T="hi"

res=any(S==T*i for i in range(1,6))
print("No Yes".split()[res])
#print(res)
# Judge status: Accepted
import math 

a, b = map(str, input().split())

c = math.sqrt(int(a + b))
if c.is_integer():
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
input()
d=dict.fromkeys('AC WA TLE RE'.split(),0)
for ln in sys.stdin:
    d[ln.strip()]+=1
for k,v in d.items():
    print(k,'x',v)
# Judge status: Accepted
S = input()
Q = int(input())
F,B = "",""
k = 1
for i in range(Q):
    q = list(input().split())
    if int(q[0])==1:k = abs(k-1)
    else:
        if int(q[1])==1:
            if k:F+=q[2]
            else:B+=q[2]
        else:
            if k:B+=q[2]
            else:F+=q[2]
if k:print(F[::-1]+S+B)
else:print(B[::-1]+S[::-1]+F)
# Judge status: Wrong Answer
N, _ = list(map(int, input().split()))
d = set(input().replace(" ", ""))

for i in range(1,100001):
  n = str(N*i)
  ns = set(list(n))
  flg = False
  for t in ns:
    if t in d:
      flg = True
      break
  if flg == False:
    print(n)
    exit()
print(0)
# Judge status: Accepted
import sys
def input():
  return sys.stdin.readline()#[:-1]

def main():
  a = list(map(int, input().split()))
  if sum(a) >= 22:
    print("bust")
  else:
    print("win")
    
if __name__ == '__main__':
  main()
# Judge status: Accepted
# AtCoder
lst = [int(input()) for _ in range(5)]
k = int(input())

if max(lst) - min(lst) > k:
    print(':(')
else:
    print('Yay!')
# Judge status: Wrong Answer
S = int(input())
a, b = divmod(S, 10**9)
if b > 0:
    b = 10**9-b
print(0, 0, 10**9, 1, b, a+1)
# Judge status: Wrong Answer
s=input()
l=list(map(int,s.split()))
n=l[0]
k=l[1]

ss=set([i+1 for i in range(n)])
work=l[2:]
counter=set([])

i=0
while True:
    if i==len(work):
        break
    for j in work[i+1:i+work[i]+1]:
        counter.add(j)
        print(counter)
        
    i=i+work[i]+1
    
for j in list(counter):
    ss.remove(j)
print(len(ss))
# Judge status: Accepted
import collections

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

#print(N,S)
#print("------------")
c = collections.Counter(S)
#print(c.most_common())
temp = c.most_common()
max_count = temp[0][1]

T = []
for i in range(N):
    if len(temp) > 1:
        if temp[i][1] == max_count:
            T.append(temp[i][0])
        else:
            break
    else:
        T.append(temp[0][0])
        break

T.sort()
for i in range(len(T)):
    print(T[i])
# Judge status: Wrong Answer
C = []
A = input()
for i in A:
    if i == '0':
        C.append(i)
    if i == '1':
        C.append(i)
    if i == 'B' and  len(C)!=0:
        C.pop()

print(C)
# Judge status: Wrong Answer
o=list(input())
m=list(input())
ans=' '
for i in range(len(o)-1):
            
                        ans +=o[i]
                        ans +=m[i]

ans+=o[-1] 
print(ans)
# Judge status: Accepted
import heapq

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

for i in range(N):
    A[i] *= -1
heapq.heapify(A)


for i in range(M):
    b = heapq.heappop(A) * (-1)
    heapq.heappush(A, (b // 2) * (-1))
    

print(sum(A) * -1)
# Judge status: Accepted
K,S=map(int,input().split())
cnt=0
for x in range(K+1):
    for y in range(K+1):
        z=S-x-y
        if(0<=z<=K):
            cnt+=1
print(cnt)
# Judge status: Accepted
d, t, s = map(int, input().split())

if d / s <= t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, W = list(map(int, input().split(" ")))
dp =  [[0] * (W+1) for _ in range(N+1)]
 
for i in range(0, N):
	weight, value = map(int, input().split(" "))
	for w in range(1, W+1):
		if w >= weight:
			dp[i + 1][w] = max([dp[i][w - weight] + value, dp[i][w]])
		else:
			dp[i + 1][w] = dp[i][w]
print(dp[N][W])
# Judge status: Accepted
x=int(input())
a=(x//11)*2
print(a if x%11==0 else a+1 if x%11<7 else a+2)
# Judge status: Accepted
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   return ceil((N-1) /(K - 1))

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
from collections import Counter

N = int(input())
S = input()

MOD = 10**9 + 7
cnt = Counter(S)
ans = 1
for i in cnt.values():
    ans *= (i + 1) % MOD
print(ans-1)
# Judge status: Accepted
N = int(input())
S = input()
x = S.count('E') - (1 if S[0] == 'E' else 0)
ans = x
for s1, s2 in zip(S, S[1:]):
    if s1 == 'W':
        x += 1
    if s2 == 'E':
        x -= 1
    ans = min(ans, x)
print(ans)
# Judge status: Wrong Answer
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    print(a[0]+a[1] %24)
# Judge status: Accepted
a,b,c = map(int,input().split())
if a == b+c or b == a+c or c == a+b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, r = map(int, input().split())

print(r + max(10 - n, 0) * 100)
# Judge status: Accepted
x,y=map(int,input().split())

n=[0,1,3,1,2,1,2,1,1,2,1,2,1]

if n[x]==n[y]:
    ans="Yes"
else:
    ans="No"
            
print(ans)
# Judge status: Accepted
x = int(input())
y = x//100
if x%100<=5*y:
    print(1)
else:
    print(0)
# Judge status: Accepted
S=str(input())
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())

if n < 10:
    print(n)
else:
    n = str(n)
    l = len(n)
    if n == n[0] + '9'*(l-1):
        print(int(n[0]) + 9 * (l-1))
    else:
        print(int(n[0]) + 9*(l-1) -1)
# Judge status: Wrong Answer
A,B = map(int,input().split())
import fractions
print(fractions.gcd(A,B))
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    ans += p[i] == sorted(p[i - 1:i + 2])[1]
print(ans)
# Judge status: Accepted
import numpy as np

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

before = np.array(P)
after = np.sort(before)
sort_cnt = np.count_nonzero(before - after)

print('YES' if sort_cnt <= 2 else 'NO')
# Judge status: Wrong Answer

h = int(input())

fighting_monster_hp = h
fighting_monster_number = 1
total_attack = 0

while 1 < fighting_monster_hp:
    # 今の敵を倒す
    total_attack = total_attack + fighting_monster_number
    # 次の敵が出現
    fighting_monster_hp = fighting_monster_hp / 2
    fighting_monster_number = fighting_monster_number * 2

# 敵のHPが1になったので、今いる敵でおしまい
# h = 1000000000000で合わないのはなぜ?
if h < 1024:
    total_attack = total_attack + fighting_monster_number

print(total_attack)
# Judge status: Accepted
abc = list(map(int, input().split()))
abc_max = max(abc)
abc2 = abc
abc2.remove(abc_max)

if abc_max == sum(abc2):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer

k=int(input())
a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,k):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)
# Judge status: Wrong Answer
#C - City Savers

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
ad = 0

for i in range(N):
  if A[i] <= B[i] + ad:
    count += A[i]
    ad = max(0, B[i] - max(A[i] - ad, 0))
    print(count, ad)
  else:
    count += B[i] + ad
    ad = 0
    print(count, ad)

count += min(A[N], ad)     

print(count)
# Judge status: Accepted
n, k = map(int, input().split())
a = [i for i in range(n+1)]
mod = 10**9+7
ans = 0
for i in range(k, n+2):
  L = i * (i - 1) / 2
  R = n * i - i * (i - 1) / 2
  ans += R - L + 1
  ans %= mod
print(int(ans))
# Judge status: Wrong Answer
#-*-coding:utf-8-*-

def main():
    a,b,x = map(int,input().split())

    if b-x+a==x:
        print("YES")
    else:
        print("NO")

if __name__=="__main__":
    main()
# Judge status: Wrong Answer
D = int(input())

print('Chiristmas'+' Eve'*(25-D))
# Judge status: Wrong Answer
a, b, c = input().split()
if int(a+b) > int(c):
  print(int(a+b) + int(c))
else:
  print(int(a) + int(b+c))
# Judge status: Accepted
L,R,d = map(int,input().split())
r = R//d
l = L//d
if L%d == 0:
    ans = r-l + 1
else:
    ans = r-l
print(ans)
# Judge status: Accepted
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    S1 = S()
    T = S()

    cnt = 0

    for i, s in enumerate(S1):
        if T[i] != s:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(key=lambda x:x[1], reverse=True)
D = []
d = 0
for b, c in BC:
    D += [c]*b
    d += b
    if d >= N:
        break
for i in range(N):
    if i < d and A[i] < D[i]:
        A[i] = D[i]
    else:
        break
print (sum(A))
# Judge status: Accepted
N = int(input())
S = input()
MOD = 10**9+7
d = {}
for i in range(N):
  if S[i] in d:
    d[S[i]].append(i)
  else:
    d[S[i]] = [i]
ans = 1
for k,v in d.items():
  ans *= len(v)+1
  ans %= MOD
print((ans-1)%MOD)
# Judge status: Accepted
#ABC043Bprint(1,end='')
s=input()
s_=[]
for i in range(len(s)):
    if s[i]=="1":
        s_.append("1")
    if s[i]=="0":
        s_.append("0")
    if s[i]=="B":
        if len(s_)!=0:
            s_.pop()

print(''.join(s_))
# Judge status: Accepted
a=int(input())
n=2*(a//11)+a%11//7+min(1,a%11)
print(n)
# Judge status: Accepted
X = int(input())
a = X
while 1:
  f = 1
  for b in range(2, X):
    if a % b == 0:
      f = 0
      break
  if f == 1:
    print(a)
    break
  a += 1
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    if sum(A) > sum(B):
        print('No')
        exit()
    
    cnt = 0
    for i in range(N):
        if B[i] > A[i]:
            cnt += (B[i] - A[i]) // 2
        else:
            cnt -= (A[i] - B[i])

    if cnt >= 0:
        print('Yes')
    else:
        print('No')
    


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x, k, d = map(int, input().split())
if k <= x//d:
    if x:
        x -= k*d
        k = 0
    else:
        x += k*d
        k = 0
else:
    k -= x//d
    x %= d
if k%2:
    if x:
        x = -(x-d)
    else:
        x = x-d
print(abs(x))
# Judge status: Accepted
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10**9)
from collections import deque,defaultdict
import heapq
from itertools import combinations
import bisect

n=int(input())
l=[]
p=[]
q=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([2*a,2*b])
    p.append(2*a)
    q.append(2*b)
p.sort()
q.sort()
if n%2==0:
    al=(p[n//2]+p[n//2-1])//2
    ar=(q[n//2]+q[n//2-1])//2
else:
    al=p[n//2]//2
    ar=q[n//2]//2
print(ar-al+1)
# Judge status: Wrong Answer
N,K=map(int,input().split())
price=list(map(int,input().split()))
price.sort()
price_K=price[:K]
j=0
for i in price_K:
  j+=i
  print(j)
# Judge status: Wrong Answer
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

x = y = t = 0
for i in range(n):
    dx, dy, dt = l[i][1], l[i][2], l[i][0]
    dist = abs((dx - x) + (dy - y))

    if abs(dt - t) < dist or dt - dist:
        print("No")
        exit()

    x, y, t = dx, dy, dt
print("Yes")
# Judge status: Accepted
# -*- coding: utf-8 -*-

n = int(input())
a = [int(ai) for ai in input().split()]
order = {a[i]: i+1 for i in range(len(a))}

print(' '.join(map(str, list(order.values()))))
# Judge status: Wrong Answer
import math
a, b = map(int, input().split())
if(math.ceil(a/0.08) < math.ceil(b/0.1)):
    print(-1)
else:
    print(math.ceil(a/0.08))
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(m):
    l.append(list(map(int, input().split())))
l.sort(reverse=True)
l2 = []
for i in range(m):
  l2 = l2 + [l[i][1] for _ in range(l[i][0])]
  if len(l2) >= n:
    l2 = l2[:n]
    break
a = a + l2
a.sort(reverse=True)
print(sum(a[:n]))
# Judge status: Accepted
import sys
import collections
N, K = map(int, sys.stdin.readline().split(" "))
A = list(map(int, sys.stdin.readline().split(" ")))
C = sorted(list(collections.Counter(A).values()), reverse = True)
print(sum(C[K:]))
# Judge status: Wrong Answer
A,B=map(int,input().split())
K=(A+B)/2
if(K.is_integer()==True):
  print(K)
else:
  print("Impossible")
# Judge status: Accepted
n = int(input())
w = list(map(int, input().split()))
ans_list = []

for t in range(1, n):
  ans_list.append(abs(sum(w[:t])-sum(w[t:])))

print(min(ans_list))
# Judge status: Wrong Answer
n = int(input())
l=[int(input()) for x in range(n)]
setl=list(set(l))
m=max(l)
if len(setl)==1:
    print(m)
    exit()
else:
    second=setl[-2]
for i in range(n):
    if l[i]==m:
        print(second)
    else:
        print(m)
# Judge status: Accepted
a,b=map(int,input().split())
if a>0:
  print("Positive")
elif a==0 or b==0:
  print("Zero")
elif b<0:
  n=(-a)+b-1 
  if n%2==0:
    print("Positive") 
  else:
    print("Negative") 
else:
  print("Zero")
# Judge status: Accepted


import numpy as np

input()
#a=sorted(list(map(int,input().split())),reverse=True)
a=sorted(map(int,input().split()),reverse=True)
#print(a)
ans=sum(a[::2])-sum(a[1::2])
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
c=1
g=0
for i in range(n-1):
  if (g==1 and a[i+1]<a[i]) or (g==-1 and a[i+1]>a[i]) :
    c+=1
    g=0
  elif g==0:
    if a[i+1]>a[i]:
      g=1
    elif a[i+1]<a[i]:
      g=-1
print(c)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))

d=[0]*n
for i in range(n):
    d[a[i]-1]+=1

d.sort(reverse=True)

sm=0
for i in range(k):
    if i>=n:
        break
    sm+=d[i]

print(n-sm)