peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    X, K, D = readnums()
    if X // D >= K:
        print(X - K * D)
    else:
        a1 = X % D
        a2 = D - X % D
        if (K - X // D) % 2:
            print(a2)
        else:
            print(a1)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
X = int(input())
P = math.ceil((-1+(1+8*X)**(1/2))/2)
print(P)
# Judge status: Accepted
n=int(input())
if n%2==1:
    print(0)
else:
    ans=0
    i=1
    while 5**i*2<=n:
        ans+=n//(5**i*2)
        i+=1
    print(ans)
# Judge status: Accepted
def main():
    N, M = (int(i) for i in input().split())
    from heapq import heapify, heappop, heappush
    from collections import defaultdict
    sche = defaultdict(list)
    for i in range(N):
        a, b = (int(i) for i in input().split())
        sche[a].append(b)

    q = []
    heapify(q)

    ans = 0
    for i in range(1, M+1):
        for s in sche[i]:
            heappush(q, -s)
        if q:
            ans += -heappop(q)

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
A = sorted(list(set(A)), reverse=True)

N = len(A)
if N == 1:
    print(0)
    exit()

ans = 0
for i in range(N-1):
    flag = True
    for j in range(i+1, N):
        if A[i] % A[j] == 0:
            flag = False
            break
    if flag:
        ans += 1

print(ans+1)
# Judge status: Accepted
import itertools

def main():
    N = int(input())
    P = input().replace(" ", "")
    Q = input().replace(" ", "")
    vals = []
    for comb in itertools.permutations(list(map(str, range(1, N+1))), N):
        vals.append("".join(comb))
    vals.sort()
    print(abs(vals.index(P) - vals.index(Q)))


if __name__ == '__main__':
    main()
# Judge status: Accepted
d, n = map(int, input().split())
arr = []
i = 1
while len(arr) != n:
  if 100 ** d * i % 100 ** (d + 1) != 0:
    arr.append(100 ** d * i)
  i += 1
print(arr[-1])
# Judge status: Accepted

def main():
    s = list(input())[::-1]
    ary_mod = [0] * 2019
    ary_mod[0] = 1
    now = 0
    digit = 1
    for i, ss in enumerate(s):
        now += int(ss) * digit % 2019
        digit *= 10
        digit %= 2019
        remind = now % 2019
        ary_mod[remind] += 1
    ans = 0
    for i, n in enumerate(ary_mod):
        ans += (n*(n-1)) // 2
    print(ans)
if __name__=='__main__':
    main()
# Judge status: Accepted
n ,k = list(map(int, input().split()))
p_list = list(map(int,input().split()))

p_list.sort()
ans = sum(p_list[0:k])
print(ans)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
#a = Takahashi's HP,b = T's ATK, c = Aoki's HP, d = A's ATK
#T -> A -> T -> A...
print("Yes" if -(-a//d) >= -(-c//b) else "No")
# Judge status: Wrong Answer
n, *a = map(int, open(0).read().split())
cnt = 0
a = [0] + a
i = 1
while 1:
    tmp = i
    i = a[i]
    cnt += 1
    if tmp == i:
        print(-1)
        break
    elif a[i] == 2:
        print(cnt+1)
        break
    elif cnt >= n:
        print(-1)
        break
# Judge status: Wrong Answer
s = raw_input()
if 'a' or 'b' or 'c' in s:
    print 'Yes'
elif 'a' or 'b' or 'c' not in s:
    print 'No'
# Judge status: Accepted
a,b,c = sorted(map(int,input().split()))
if (c-a)%2 ==0 and (c-b)%2 == 0:
  print((c-a)//2+(c-b)//2)
elif (c-a)%2 == 1 and (c-b)%2 == 1:
  print((2*c-b-a-2)//2+1)
elif (c-a)%2 == 0:
  print((c-a)//2+(c+1-b)//2+1)
else:
  print((c+1-a)//2+(c-b)//2+1)
# Judge status: Accepted
n, m = map(int, input().split())
if n < 2 and m < 2:
    ans = 1
elif n < 2:
    ans = m - 2
elif m < 2:
    ans = n - 2
else:
    ans = n * m - (2 * n + 2 * m - 4)
print(ans)
# Judge status: Wrong Answer
n,k,*a=map(int,open(0).read().split())
for _ in range(k):
 b=[0]*n
 for i,q in enumerate(a):
  b[max(0,i-q)]+=1
  if i+q+1<n:b[i+q+1]-=1
  for i in range(1,n):b[i]+=b[i-1]
  if b==a:break
  a=b[:]
print(*a)
# Judge status: Wrong Answer
S = input()
res = [0]*(len(S)+1)

# 左から探索
for i in range(len(S)):
  if S[i]=='<':
    res[i+1]=res[i]+1
    
for i in range(len(S)-1,0,-1):
  if S[i]=='>':
    res[i]=max(res[i],res[i+1]+1)
    
print(res)
print(sum(res))
# Judge status: Accepted
A, B = map(int,input().split())

if A == 1:
    A += 13
if B == 1:
    B += 13

if A > B :
    print('Alice')
elif B > A :
    print('Bob')
else:
    print('Draw')
# Judge status: Wrong Answer
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if ((500*i)+(100*j)+(50*k))==0:
                count+=1

print(count)
# Judge status: Wrong Answer
a=sorted(list(map(int,input().split())))
print(a[0]*a[1])
# Judge status: Accepted
N,K = map(int,input().split())
S = input()
print(min(sum(S[n]==S[n+1] for n in range(N-1))+2*K,N-1))
# Judge status: Accepted
a, b, c, d = map(int, input().split())

a_b = set(range(a,b))
c_d = set(range(c,d))

time = a_b & c_d

print(len(time))
# Judge status: Wrong Answer
def solve():
    Q, H, S, D = [int(i) for i in input().split()]
    P = [(0.25, Q), (0.5, H), (1, S), (2, D)]
    P.sort(key=lambda t: t[1] / t[0])
    N = int(input())
    ans = 0
    for p in P:
        if N == 0:
            break
        x, y = p
        n = N // x
        ans += n * y
        N -= n * x
    print(int(ans))


if __name__ == "__main__":
    solve()
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = readline().rstrip().decode()[::-1]
memo = ['2', '4', '5', '7', '9']
memo1 = ['0', '1', '6', '8']
if n[0] in memo:
    print('hon')
elif n[0] in memo1:
    print('pon')
else:
    print('bon')
# Judge status: Accepted
from collections import defaultdict

N = int(input())
A = [0]+list(map(int, input().split()))

d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(1, N+1):
    d1[i-A[i]] += 1
    d2[i+A[i]] += 1

ans = 0
for k in d1.keys():
    ans += d1[k]*d2[k]
print(ans)
# Judge status: Wrong Answer
N = int(input())
ans = 0

for i in range(1, N):
  if i % 3 != 0 and i % 5 != 0:
    ans += i

print(ans)
# Judge status: Accepted
s = input()
if s[-1] == 's':
  print(f'{s}es')
else:
  print(f'{s}s')
# Judge status: Accepted
R = int(input())
print(6.283185307179586*R)
# Judge status: Accepted
n, m, x = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(n)]

# rについて表裏のすべての組み合わせを調べる。
ans = 10 ** 19
for b in range(2 ** n):
  aa = [0] * m
  amn = 0
  for i in range(n):
    if (b >> i) & 1:
      amn += CA[i][0]
      for k in range(m):
        aa[k] += CA[i][k + 1]
  if all(a >= x for a in aa):
    ans = min(ans, amn)  

if ans == (10 ** 19):
  print(-1)
else:
  print(ans)
# Judge status: Wrong Answer
x,a,b=map(int,input().split())
print('delicious' if b-a<0 and b-a<=x else ('safe' if b-a<=x else 'dangerous'))
# Judge status: Accepted
x, y=map(int, input().split())
A=set([1, 3, 5, 7, 8, 10, 12])
B=set([4, 6, 9, 11])
if x in A and y in A:
  print('Yes')
elif x in B and y in B:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n, k = map(int, input().split())
h = list(sorted(map(int, input().split())))
x = 0
if n > k:
    for i in range(n - k):
        x += h[i]

print(x)
# Judge status: Accepted
N=int(input())
L=[int(i) for i in input().split()]
long=max(L)
#print(long)
L.remove(long)
if long<sum(L):
  #print(sum(L))
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
x=str(input())
print(["Sunny","Cloudy"][x=="Sunny"])
# Judge status: Accepted
a = int(input())
print(a**3 + a**2 + a)
# Judge status: Accepted
# vim: fileencoding=utf-8


def main():
    x, y, z = input().split()
    num = int(x + y + z)
    if num % 4:
        print("NO")
    else:
        print("YES")


if __name__ == "__main__":
    main()
# Judge status: Accepted
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))


for i in range(K,N):
    if A[i]>A[i-K]:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
N = int(input())

if N == 1:
    print(0)

else:
    print(int(N * (N - 1) / 2))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

cnt=0
c=1

for i in range(n):
  if a[i]!=c:
    cnt+=1
  else:
    c+=1
    
if cnt==n:
  print(-1)
else:
  print(cnt)
# Judge status: Wrong Answer
x = int(input())
ans = 8
if 600<=x<800: ans=7
elif x<1000: ans=6
elif x<1200: ans=5
elif x<1400: ans=4
elif x<1600: ans=3
elif x<1800: ans=2
elif x<2000: ans=1
print(ans)
# Judge status: Accepted
n = int(input())
a = int(input())

print("Yes" if a >= n - 500*(n//500) else "No")
# Judge status: Wrong Answer
import math
N = int(input())
A = list(map(int,input().split()))
l = list()
ll = list()
lll = list()
for i in range(len(A)):
  if A[i]%4 == 0:
    l.append(A[i])
  if A[i]%2 == 0:
    ll.append(A[i])
  if A[i]%2 != 0:
    lll.append(A[i])
four = len(l)
two = four - len(ll)
zero = N-two
a = math.floor(N/2)
b = A.count(0)

if zero <= four and b == 0:
  print("Yes")
elif zero-two <= four:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
S = list(str(input()))
K = int(input())

ind = 0
for s in S:
    i = int(s)

    if i == 1:
        num = pow(i, 5000000000000000)
        if num + ind >= K:
            print(i)
            break
        else:
            ind += num
    else:
        print(i)
        break
# Judge status: Wrong Answer
A,B,C,X,Y=map(int,input().split())
if A+B<2*C:
  ans=A*X+B*Y
else:
  if X<=Y:
    ans=C*2*X
    if 2*C<=B:
      ans+=2*C*(Y-X)
    else:
      ans+=B*(Y-X)
  else:
    ans=C*2*Y
    if Y<=X:
      ans+=2*C*(X-Y)
    else:
      ans+=B*(Y-X)
print(ans)
# Judge status: Wrong Answer
import itertools


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


accA = list(itertools.accumulate(a))
accB = list(itertools.accumulate(b))


cnt = 0
ans = 0
for i in range(len(accA)):
    for j in range(len(accB)):
        if k >= accA[i]+accB[j]:
            cnt = i+j
        
        ans = max(cnt, ans)


print(ans)
# Judge status: Wrong Answer
x,y=map(int,input().split())
if(x>8 or y>8):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))


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

ans = 0
last = -1
for i in range(n):
    ans += b[a[i] -1]
    if (last + 1 == a[i]):
        ans += c[a[i] -2]
    last = a[i]
print(ans)
# Judge status: Accepted
S=input()
print(S+'es' if S[-1]=='s'else S+'s')
# Judge status: Wrong Answer
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
       tmp = int(c[i]) // 2
       for j in range(tmp):
           lists.append(i)
lists.sort()
lists.reverse()
Max = -999999999
if len(lists) > 1:
    for i in range(len(lists)-1):
        ans = int(lists[i]) * int(lists[i+1])
        if ans > Max:
            Max = ans
else:
    Max = 0
print(Max)
# Judge status: Accepted
S = input()
frag = True
c = 0
for i in S:
    if c%2==0:
        if i=='L':
            frag = False
    if c%2==1:
        if i=='R':
            frag = False
    c+=1
if frag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,readline().split())

if n == m:
    print("Draw")
elif n==1 or m == 1:
    if n ==1:
        print("Alice")
    else:
        print("Bob")
else:
    if n > m:
        print("Alice")
    else:
        print("Bob")
# Judge status: Accepted
n = int(input())
if n%2 == 1:
    print(0)
    exit()
num = 5
i = 1
ans = 0
while num**i < n:
    ans += n//num**i//2
    i += 1
print(ans)
# Judge status: Wrong Answer
n = int(input())
print((n+2-1)/2)
# Judge status: Accepted
W, H, N = map(int, input().split())
XYA = [list(map(int, input().split())) for _ in range(N)]

x_min = max([0] + [xya[0] for xya in XYA if xya[2] == 1])
x_max = min([W] + [xya[0] for xya in XYA if xya[2] == 2])
y_min = max([0] + [xya[1] for xya in XYA if xya[2] == 3])
y_max = min([H] + [xya[1] for xya in XYA if xya[2] == 4])
print(max(x_max - x_min, 0) * max(y_max - y_min, 0))
# Judge status: Accepted
n=list(map(int,input()))

if (n[0]==n[1]and n[1]==n[2]) or (n[1]==n[2] and n[2]==n[3]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
mod = 10**9 + 7
n = int(input())
ans = 1
for i in range(1, n+1):
  ans *= i
  ans %= mod
print(ans)
# Judge status: Wrong Answer
R=int(input())
p=3.141516
print(R*p)
# Judge status: Wrong Answer
n=int(input())

if 100<=n<=111:
            print(111)
a=0
for a in range(1,8):
            if 1+111*a<=n<=111*(a+1):
                        print(111*(a+1))
# Judge status: Accepted
n = int(input())

ALL = (10 ** n) % (10**9 +7)
wo_0 = (9 ** n) % (10**9 +7)
wo_9 = (9 ** n) % (10**9 +7)
wo_0_9 = (8 ** n) % (10**9 +7)

ans = (ALL - (wo_0 + wo_9 - wo_0_9)) % (10**9 +7)
print(ans)
# Judge status: Accepted
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

t = sum(B)

# しゃくとり法
res = 0
j = m
for i in range(n + 1):
    while j > 0 and t > k:
        j -= 1
        t -= B[j]
    if t > k:
        break
    res = max(res, i + j)
    if i == n: break
    t += A[i]

print(res)
# Judge status: Wrong Answer
a,b = input().split()
print(a+b)
# Judge status: Accepted
x = int(input())


if x >= 400 and x <= 599:
    print('8')
if x >= 600 and x <= 799:
    print('7')
if x >= 800 and x <= 999:
    print('6')
if x >= 1000 and x <= 1199:
    print('5')
if x >= 1200 and x <= 1399:
    print('4')
if x >= 1400 and x <= 1599:
    print('3')
if x >= 1600 and x <= 1799:
    print('2')
if x >= 1800 and x <= 1999:
    print('1')
# Judge status: Accepted
S=input()
c=[0]*(len(S) + 1)
for i in range(len(S)):
    if S[i]=="<":
        c[i+1]=c[i]+1

for j in range(len(S)-1,-1,-1):
    if S[j]==">":
        c[j] = max(c[j], c[j+1]+1) 
print(sum(c))
# Judge status: Accepted
S = input()
T = input()
max_count = 0
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            count += 1
    max_count = max(max_count, count)
print(len(T) - max_count)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
b = 0
C = []

for a in A:
  b^=a

for a in A:
  C.append(a^b)

print(*C)
# Judge status: Accepted
n = int(input())
s = input()

l_num, r_num = 0, 0
for i in s:
    if i == '(':
        l_num += 1
    elif l_num <= 0:
        r_num += 1
    else:
        l_num -= 1
print('(' * r_num + s + ')' * l_num)
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
jud = 1
q = a[0]
ans = 0
for i in range(1,n):
  if(q==a[i]):
    jud += 1
  else: 
    if(jud%2==1):
      ans += 1
    jud = 1
    q = a[i]
if (jud%2==1)and(jud>2):
  ans += 1
if(n==1):
  ans = 1
print(ans)
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
c = [1]*n
r = set([0])
for i in range(m):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    if c[x]==1 and x in r:
        r.remove(x)
        r.add(y)
    elif c[x]>=2 and x in r:
        r.add(y)
    c[x] -= 1
    c[y] += 1
print(len(r))
# Judge status: Accepted
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())

ans = 0
s = set()

while N not in s:
    s.add(N)
    if N%2==0:
        N //= 2
    else:
        N = N*3+1
    ans += 1

print(ans+1)
# Judge status: Accepted
nk = input()
nk = nk.split()
[n,k] = nk
n, k = int(n), int(k)
ans = 0
for s in range(k, n + 2):
    temp = s*(n-s+1) + 1
    ans += temp
    if(ans > 1000000007):
        ans = ans % 1000000007
print(ans)
# Judge status: Accepted
N, D = map(int, input().split())
d = D*2 + 1

print((N - 1) // d + 1)
# Judge status: Accepted
import fractions

N = int(input())
A = list(map(int, input().split()))
L = A[0]
for i in range(1, N):
    L = L * A[i] // fractions.gcd(L, A[i])

ans = 0
for i in range(N):
    ans = (ans + L // A[i]) #% 1000000007

print(ans%1000000007)
# Judge status: Accepted
N = int(input())
count=0
for i in range(1,N+1):
  if not(i%3==0 or i%5==0):
    count+=i
print(count)
# Judge status: Accepted
import numpy as np
a = input()
N = int(a)

xy = [map(int, input().split()) for _ in range(N)]
x, y = np.array([list(i) for i in zip(*xy)])

z = x + y
w = x - y

ans = max((max(z)-min(z)),(max(w)-min(w)))
print(ans)
# Judge status: Accepted
n = int(input())

top1= -10**10
bot1= 10**10
top2= -10**10
bot2= 10**10
for _ in range(n):
	
	x,y = map(int, input().split(' '))
	tot1= x+y
	tot2= x-y
	if tot1> top1:
		top1= tot1
	if tot1< bot1:
		bot1= tot1
	if tot2>top2:
		top2= tot2
	if tot2<bot2:
		bot2= tot2

print(max(top1-bot1, top2-bot2))
# Judge status: Accepted
import heapq
import math

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

B = [-A[i] for i in range(N)]
heapq.heapify(B)
while M:
    p = heapq.heappop(B)
    p /= 2
    heapq.heappush(B, p)
    M -= 1

ans = 0
for i in range(N):
    ans += math.floor(-B[i])
print(ans)
# Judge status: Accepted
s=input()
t=input()
lis=sorted(list(s))
lit=sorted(list(t),reverse=1)
print("Yes" if "".join(lis) < "".join(lit) else "No")
# Judge status: Wrong Answer
a,b = map(int, input().split())

if a<=8 and b<=8:
  print('Yay')
else:
  print(':(')
# Judge status: Wrong Answer
import numpy as np
n = int(input())
mod = 10**9+7
a = np.array(list(map(int,input().split())))
ans = 0
for i in range(60):
    #aをiビット右にずらす、iは60桁目まで、&1で対象のビットが1のもの以外を0にその数をカウントする。
    b = np.count_nonzero(a >>i&1)
    ans += ((2**i)*(n-b)*b)%mod
print(ans)
# Judge status: Accepted
from heapq import heappop, heappush

n,m=map(int,input().split())
l=[]
for _ in range(n):
    a,b=map(int,input().split())
    if a>m:continue
    l.append((a,b))

l.sort(reverse=True)

q=[]
ans=0

for i in range(1,m+1):
    while l and l[-1][0]<=i:
        a,b=l.pop()
        heappush(q,-b)
    if q:
        b=-heappop(q)
        ans+=b
print(ans)
# Judge status: Accepted
N=int(input())
d=list(map(int,input().split()))
d=sorted(d)
print(d[int(N/2)]-d[int((N/2))-1])
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
fav = set(range(1, m+1))
for _ in range(n):
    a = set(list(map(int, input().split()))[1:])
    fav = fav.intersection(a)

print(len(fav))
# Judge status: Accepted
w,a,b=map(int,input().split())
a,b=min(a,b),max(a,b)
if b-a-w>=0:
  print(b-a-w)
else:
  print(0)
# Judge status: Accepted
import fractions 

n,X=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]=abs(x[i]-X)

ans=10**10
if n==1:
    print(x[0])
    exit()
for g in range(1,n):
    ans=min(ans,fractions.gcd(x[g-1],x[g]))
print(ans)
# Judge status: Accepted
s = input()
sl = list(s)
for i in range(len(sl)):
    if (i + 1) % 2 == 1:
        if sl[i] == 'L':
            print('No')
            break
        else:
            continue
    else:
        if sl[i] == 'R':
            print('No')
            break
        else:
            continue
else:
    print('Yes')
# Judge status: Wrong Answer
h, a = [int(i) for i in input().split()]
print(h//a + 1 if h % a > 0 else 0)
# Judge status: Wrong Answer
l,r,d=map(int,input().split())
ans=0
for i in range(l,r+1):
    if i%2==0:
        ans+=1
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())

if max(a,b,c)==a+b+c-max(a,b,c):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
w = str(input())
for i in range(len(w)):
  for j in range(len(w)):
    if i != j:
      if w[i] == w[j]:
        f = True
        break
      else:
        f = False
    else:
      f = False
print('no' if f else 'yes')
# Judge status: Wrong Answer
a,b = input().split()
a =int(a)
b = int(b)

if (a + b) % 2 ==0:
  print((a+b)/2)
else:
  print('IMPOSSIBLE')
# Judge status: Accepted
N,K=map(int,input().split())
A=input().split()
balls=[int(a) for a in A]
answers=[0]*200000
for a in balls:
    answers[a-1]+=1
list=[a for a in answers if a!=0]
newlist=sorted(list)
n=len(newlist)-K
answer=0
for a in range(n):
    answer+=newlist[a]
print(answer)
# Judge status: Wrong Answer
x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
#print(x,n)
#print(p)
#print(max(p))
y = 100
ans = n
if n == 0:
  print(x)
else:
  for i in range(0,101):
    if i != x:
      if p.count(i) == 0:
        #print('i=',i,abs(x-i))
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
  print(ans)
# Judge status: Accepted
x = input()
x = int(x)
if x == 0:
  print(1)
elif x == 1:
  print(0)
# Judge status: Accepted
#!python3

def LI():
    return list(map(int, input().split()))

# input
N, K = LI()


def p(x):
    ret = 1
    while x < K:
        ret /= 2
        x *= 2
    return ret


def main():
    ans = 0
    for i in range(1, N + 1):
        ans += p(i)

    ans /= N
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x = list(map(int, input().split()))
h = (x[2] - x[0])*60
m = abs(x[1] - x[3])
ans = max(m+h-x[-1], 0)
print(ans)
# Judge status: Wrong Answer
from fractions import gcd
n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans *= t/gcd(ans, t)
print(int(ans))
# Judge status: Wrong Answer
s = input()
if s[-1] == 's':
  print(s[:-1]+'es')
else:
  print(s+'s')
# Judge status: Wrong Answer
import sys

n = int(input())
a = input()
s = list(a)

right = 0
left = 0

for i in s:
    if i == "(":
        right+=1
    else:
        left+=1

for _ in range(max(0,left - right)):
    sys.stdout.write("(")
sys.stdout.write(a)
for _ in range(max(0,right - left)):
    sys.stdout.write(")")
# Judge status: Wrong Answer
N = int(input())

strs = []
dicts = {}
for i in range(N):
    s = input()
    if dicts.get(s) is not None:
        dicts[s] += 1
    else:
        dicts[s] = 1

dict_sorted = sorted(dicts.items(), key=lambda x:x[1], reverse=True)

i = 0
for s in dict_sorted:
    if dicts[s[0]] >= i:
        print(s[0])
    i = dicts[s[0]]
# Judge status: Accepted
s=input()
d={"a":0,"b":0,"c":0}
for m in s:
  d[m]+=1
if max(d["a"],d["b"],d["c"])-min(d["a"],d["b"],d["c"])>1:
  print("NO")
else:
  print("YES")
# Judge status: Accepted
n=int (input())
a= list(map(int, input().strip().split()))
b=[0]*n
for i in range(n):
    b[a[i]-1]=i+1
print(*b)
# Judge status: Accepted
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if h[a] <= h[b]:
        l[a] = 0
    if h[b] <= h[a]:
        l[b] = 0
ans = sum(l)
print(ans)
# Judge status: Accepted
from string import ascii_uppercase as upper

n = int(input())
s = input()
t = ''
for i in range(len(s)):
    t += upper[(upper.find(s[i]) + n) % 26]
print(t)
# Judge status: Wrong Answer
a = input()

if 'A' <= a and a <= 'Z':
    print('A')
elif 'a' <= a and a <= 'z':
    print(a)
# Judge status: Accepted
n,c=map(int,input().split())
x,y,z=-1,-1,-1
for i in range(n+1):
  for j in range(n+1-i):
    if 10000*i+5000*j+(n-i-j)*1000==c:
      x,y,z=i,j,n-i-j
      print(x,y,z)
      exit()
print(x,y,z)
# Judge status: Wrong Answer
N, D = list(map(int, input().split()))
 
count = 0
for _ in range(N):
    X, Y = list(map(int, input().split()))
    if (X * X + Y * Y) ** 2 <= D ** 2 :
        count += 1
print(count)
# Judge status: Accepted
def total(n):
  return int(1/2 * n * (n + 1))
 
n = int(input())
print(total(n))