peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
lis=[int(input())]
for i in range(1000):
    if lis[i]%2==0:
        a=lis[i]//2
        lis.append(a)
        if a==lis[0]:
            break
    else:
        a=lis[i]*3+1
        lis.append(a)
        if a==lis[0]:
            break
            def has_duplicates(x):
                return len(x) != len(set(x))
            if has_duplicates(lis)==True:
                break
print(len(lis))
# Judge status: Accepted
from sys import stdin

def main():

    a = stdin.readline().rstrip()
    
    if a[2] == a[3] and a[4] == a[5]:
        print("Yes")
    else:
        print("No")



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

count = 1
loop = 26
lo = 26

N -= 1

while 1:
  if lo > N:
    break
  count += 1
  lo = loop
  loop *= 26
  lo += loop 

ss = ""

for i in range(count):
  loop //= 26
  print("N:" + (str)(N) )
  print("loop : " + (str)(loop))
  tmp = N // loop
  N %= loop
  tmp += 96
  ss += chr((int)(tmp))

ss =ss[0:-1] +  chr((int)(tmp)+1)

print(ss)
# Judge status: Wrong Answer
a,b,c,d,e=(int(x)for x in input().split())
x=(c-a)*60
z1=b-d
z2=abs(z1)
if z2>=30:
    y=x-e+30
if z2<30:
    y=x-e

if y<e:
    print("0")
else:
    print(y)
# Judge status: Accepted
lst = list(map(int,input().split()))
lst.sort()
for i in range(lst[1]):
    print(lst[0],end="")
# Judge status: Wrong Answer
d = int(input())
print('Christmas' + ' EVE'*(25-d))
# Judge status: Wrong Answer
a = int(input())
b = int(input())

ans = [1,2,3]
ans.remove(a)
ans.remove(b)
print(ans)
# Judge status: Wrong Answer
a,c,b=list(map(int,input().split()))
print(c-a+b)
# Judge status: Accepted
n = int(input())
A = []
i = 0 
while i < n:
    A.append(int(input())-1)
    i += 1
used_list = [0]
count = 0
t = 0
while count < n:
    t1 = A[t] 
    count += 1
    if t1 == 1:
        break
#    if t1 in used_list:
#        count = -1
#        break
    used_list.append(t1)
    t = t1
if t1 != 1:
    count = -1
print(count)
# Judge status: Wrong Answer
def main():

    N = int(input())

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

    now_name = sorted_S[0]
    ans = 1
    for i in range(N):
        if now_name != sorted_S[i]:
            ans += 1
    
    print('{}'.format(ans))



if __name__ == '__main__':
    main()
# Judge status: Accepted
s=input()
l=[]
i=0
while i<len(s):
  k=0
  while s[i]=='<' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
  k=0
  while s[i]=='>' if i<len(s) else False:
    k+=1
    i+=1
  if k>0:
    l.append(k)
sm=0
for i in l:
  sm+=(i*(i+1))//2
for i in range(0 if s[0]=='<' else 1,len(l)-1,2):
  sm-=min(l[i],l[i+1])
 
  
print(sm)
# Judge status: Accepted
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
 
import itertools
n,m,q=n1()
s=n3(q)
 
Alist=list(itertools.combinations_with_replacement(range(1,m+1), n))
ans=0
for A in Alist:
    tmp=0
    for r in s:
        if A[r[1]-1]-A[r[0]-1]==r[2]:
            tmp+=r[3]
    ans=max(ans,tmp)
print(ans)
# Judge status: Wrong Answer
N = int(input())
if(N >= 195):
  print(3)
elif(N >= 165):
  print(2)
elif N>=105:
  print(1)
else:
  print(0)
# Judge status: Wrong Answer
#A
n = int(input())
print(n // 2 + 1)
# Judge status: Accepted
import sys
N,Y = map(int,input().split())
for x in range(min(N,Y//10000)+1):
    for y in range(min(N-x,(Y-10000*x)//5000)+1):
        z = N-x-y
        if 10000*x+5000*y+1000*z == Y:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)
# Judge status: Accepted
import sys
readline = sys.stdin.readline
from collections import Counter
N = int(readline())
C = Counter()

for _ in range(N):
    S = readline().strip()
    C[S] += 1

ma = max(C.values())
K = [k for k, v in C.items() if v == ma]
K.sort()
print('\n'.join(K))
# Judge status: Accepted
s = input()
N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")
flag = -1
if (S > 0 and N > 0) or (S == 0 and N == 0) :
    if (E > 0 and W > 0) or (E == 0 and W == 0) :
        flag = 1
if flag == 1 :
    print("Yes")
else :
    print("No")
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    ans = N * (N+1) // 2
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
# https://atcoder.jp/contests/abc155/submissions/10175015

def main():
    n = list(map(int, input()[::-1])) + [0]
    s = 0
    res = 0
    for i, ni in enumerate(n[:-1]):
        k = ni + s
        if k < 5 or (k == 5 and int(n[i + 1]) < 5):
            res += k
            s = 0
        else:
            res += 10 - k
            s = 1
    res += s
    print(res)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def main():
  n,l = list(map(int,input().split()))
  ans=0
  if l>0:
    for i in range(2,n+1):
      print(l+i-1)
      ans+= l+i-1
  else:
    for i in range(1,n+1):
      ans+=l+i-1
  print(ans)  
main()
# Judge status: Wrong Answer
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
from collections import Counter
gi = lambda : list(map(int,input().split()))
n, = gi()
occ = Counter(gi())
for k in range(1, n + 1):
	if k not in occ:
		occ[k] = 0
for k in occ:
	print(occ[k])
# Judge status: Accepted
n = int(input())
gu = [1]
ki = [0]
for i in range(0, 20):
  gu.append(gu[-1] + (-2)**(2 + 2*i))
  ki.append(ki[-1] + (-2)**(1 + 2*i))
ans = []
for i in range(20):
  if gu[-2-i] < n <= gu[-1-i]:
    ans.append('1')
    n-= (gu[-1-i]-gu[-2-i])
  else:
    ans.append('0')
  if ki[-1-i] <= n < ki[-2-i]:
    ans.append('1')
    n -= (ki[-1-i]-ki[-2-i])
  else:
    ans.append('0')
ans.append(str(n))
print(str(int(''.join(ans))))
# Judge status: Wrong Answer
N = int(input())
a = [int(input()) for i in range(N)]
print(a)
M = []
cn = 1
for i in range(N):
    if i == 0:
        Z = a[0]
    else:
        Z = a[Z-1]
        cn = cn + 1
        M.append(Z)
        if Z == 2:
            print(cn)
            exit()
       
print(-1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = [0] * n
for i in range(n-1, -1, -1):
    cnt = 0
    for j in range(i, n, i+1):
        cnt += ans[j]
    if cnt % 2 != a[i]:
        ans[i] = 1

print(sum(ans))
print(' '.join(str(i+1) for i in range(n) if ans[i]))
# Judge status: Wrong Answer

s = input()

print(["x"] * len(s))
# Judge status: Wrong Answer
n=int(input())
if n!=1:
  print(float((n/2+1)/n))
else:
  print(float(n))
# Judge status: Wrong Answer
x = int(input())
print("christmas"+" Eve"*(25-x))
# Judge status: Accepted
N = int(input())
L = [int(input()) for _ in range(5)]
L.sort()
if N%L[0]:
  ans = N//L[0] + 1 + 4
else:
  ans = N//L[0] + 4
print(ans)
# Judge status: Accepted
import sys
import math
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N, K = map(int, input().split())
print(int(((math.log(N, K)) // 1) + 1))
# Judge status: Accepted
#!/usr/bin/env python3

N, K = map(int, input().split())

if N % K == 0:
    print(0)
else:
    print(1)
# Judge status: Accepted
n = int(input())
print(2*n*(3.141592))
# Judge status: Accepted
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    ans = N//(A+B)*A
    rem = N%(A+B)
    print(ans+min(rem, A))
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
S = input()
nl = 0
nr = 0
for i in S:
    if i == ')':
        if nr > 0:
            nr -= 1
        else:
            nl += 1
    else:
        nr += 1
print(nr)
print(nl)
print('('*nl + S + ')'*nr)
# Judge status: Wrong Answer
N = int(input())
A = [int(s) for s in input().split(' ')]
B = [int(s2) for s2 in input().split(' ')]
C = [int(s3) for s3 in input().split(' ')]

#satisfaction start value
satis = 0

#find two countinuously incremental numbers
for j in A[:]:
    for k in A[1:]:
        if j+1 == k:
            satis += C[j-1]

for i in A:
    satis += B[i-1]

print(satis)
# Judge status: Accepted
N,Y = map(int, input().split())
for i in range(N+1):
    for j in range(N-i+1):
        if 10000*i + 5000*j + 1000*(N-(i+j)) == Y:
            print(i,j,(N-(i+j)))
            exit()
print(-1,-1,-1)
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))
    BC = sorted([tuple(map(int, input().split())) for _ in range(M)], key=lambda x: x[1], reverse=True)
    ind = 0
    for b, c in BC:
        for i in range(b):
            if ind == N or A[ind] >= c:
                break
            A[ind] = c
            ind += 1
    print(sum(A))


if __name__ == '__main__':
    main()
# Judge status: Accepted
x, y, a, b, c = map(int, input().split())
pa = sorted(list(map(int, input().split())), reverse=True) # 赤
qb = sorted(list(map(int, input().split())), reverse=True) # 緑
rc = list(map(int, input().split())) # 透明

ans = []
ans += pa[:x]
ans += qb[:y]
ans += rc

print(sum(sorted(ans, reverse=True)[:x+y]))
# Judge status: Wrong Answer
A,B,C = map(int, input().split())
cnt = 0
if A == B and B == C:
    print(-1)
    exit()
while True:
    if A%2 or B%2 or C%2:
        print(cnt)
        break
    temp_a = A//2
    temp_b = B//2
    temp_c = C//2
    A += 2*temp_a + temp_b + temp_c
    B += 2*temp_b + temp_a + temp_c
    C += 2*temp_c + temp_a + temp_b
    cnt += 1
# Judge status: Accepted
def solve():
    x = int(input())
    n = x // 11
    
    if x == 6:
        return 1
    elif x == n * 11:
        return 2 * n
    elif n * 11 < x <= n * 11 + 6:
        return 2 * n + 1
    elif n * 11 + 6 < x <= (n + 1) * 11:
        return 2 * (n + 1)

print(solve())
# Judge status: Accepted
S,T = input().split()
A,B = map(int, input().split())
U = input()
 
if S == U:
  A -= 1
else:
  B -= 1
  
print(A,B)
# Judge status: Wrong Answer
given = [x for x in input()]
rets  = ''
for i, v in  enumerate(given):
    if v == "B" and i != 0:
        rets = rets[:-1]
    else:
        rets += v
print(rets)
# Judge status: Wrong Answer
n, p = map(int, input().split())
a = [1 if i%2==0 else 0 for i in map(int,input().split())]
sum_a = sum(a)

if p==0:
    print(n*(n-1)-sum_a*(n-sum_a))
else:
    print(sum_a*(n-sum_a))
# Judge status: Accepted
N = int(input())
S = []
a = 101
for i in range(N):
    s = int(input())
    if s % 10 != 0:
        a = min(s,a)
    S.append(s)
S.sort()
ans = sum(S)
if ans % 10 == 0:
    if a != 101:
        ans = ans - a
    else:
        ans = 0
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for j in range(m)]
S = list(set(s))
T = list(set(t))

for x in range(len(S)):
  a = s.count(S[x]) - t.count(S[x])
  ans = max(0, a)
print(ans)
# Judge status: Wrong Answer
a = list(map(str, input().split()))
b = list(map(str, input().split()))
c = list(map(str, input().split()))

n = 'a'

while True:
  if n == 'a':
    if len(a) == 0:
      print('A')
      break
    else:
      n = a.pop(0)
  elif n == 'b':
    if len(b) == 0:
      print('B')
      break
    else:
      n = b.pop(0)
  else:
    if len(c) == 0:
      print('C')
      break
    else:
      n = c.pop(0)
# Judge status: Accepted
w,a,b=map(int,input().split())

if a<=b:
  if a+w<b:
    print(b-a-w)
  else:
    print(0)
    
else:
  if b+w<a:
    print(a-b-w)
  else:
    print(0)
# Judge status: Wrong Answer
a, b = map(int, input().split())
num = 0
for i in range(1, a):
  num += i
  if num >= a:
    break
num -= a
print(num)
# Judge status: Wrong Answer
n,m = map(int,input().split())

red = [0 for i in range(n)]
amount = [1 for i in range(n)]
red[0] = 1
for _ in range(m):
    x,y = map(int,input().split())
    amount[x-1] -= 1
    amount[y-1] += 1
    if red[x-1]:
      red[y-1] = 1

ans = 0
for r,a in zip(red, amount):
  if r > 0 and a > 0:
    ans += 1

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

print(1+math.ceil((B-A)/(A-1)))
# Judge status: Accepted
"""
author : halo2halo
date : 16, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B, K = map(int, readline().split())
lis=[]
for i in range(1, min(A, B) + 1):

    if A % i == 0 and B % i == 0:
        lis.append(i)
lis.reverse()
print(lis[K-1])
# Judge status: Accepted
#python3
from collections import Counter
n = int(input())
a = [str(i) for i in range(100, 1000) if len(Counter(str(i))) == 1]
for i in a:
    if n <= int(i):
        print(i)
        break
# Judge status: Accepted
K = int(input())


def dfs(d, n, buf):
    buf.append(n)

    if d == 10:
        return

    lsd = n % 10

    if lsd != 0:
        dfs(d + 1, n * 10 + lsd - 1, buf)

    dfs(d + 1, n * 10 + lsd, buf)

    if lsd != 9:
        dfs(d + 1, n * 10 + lsd + 1, buf)


buf = []

for n in range(1, 10):
    dfs(1, n, buf)

print(sorted(buf)[K - 1])
# Judge status: Wrong Answer
s = input()
ans = [0 for i in range(len(s)+1)]

for i in range(1,len(s)):
    if s[i] == '<':
        ans[i+1] = ans[i]+1
for i in range(len(s)-1,-1,-1):
    if s[i] == '>':
        ans[i] = max(ans[i],ans[i+1]+1)

print(sum(ans))
# Judge status: Wrong Answer
N = input()

S = max(set(N))

print(S * 3)
# Judge status: Accepted
ABC = sorted(map(int, input().split()))
K = int(input())

print(ABC[0] + ABC[1] + ABC[2] * 2**K)
# Judge status: Accepted
x,k,d = map(int,input().split())

x = abs(x)
a = x // d
b = k - a

if b < 0:
    s = abs(x - k * d)
else:
    if b % 2 == 0:
        s = abs(x - a * d)
    else:
        s = abs(x - (a+1) * d)

print(s)
# Judge status: Accepted
s=input()
if s.isupper():
    print("A")
else:
    print("a")
# Judge status: Accepted
k,x = map(int,input().split())
print(*[x+i for i in range(-k+1, k)])
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
min_cost = float("inf")
for num in range(-100, 101):
    cost = 0
    for a in A:
        cost += (a - num) ** 2
    min_cost = min(min_cost, cost)
print(min_cost)
# Judge status: Wrong Answer
def solve():
    N = int(input())
    s = [int(input()) for _ in range(N)]
    s.sort()
    ans = sum(s)

    i = 0
    while ans % 10 == 0:
        if i == N:
            print(0)
            return
        ans -= s[i]
        i += 1
    
    print(ans)

if __name__ == '__main__':
    solve()
# Judge status: Accepted
N,M = map(int,input().split())
A = list(map(int,input().split()))

L = []
for i in range(M):
    bc = tuple(map(int,input().split()))
    L.append(bc)

L = sorted(L,key=lambda x:-x[1])
n = 0
for b,c in L:
    n += b
    A += [c] * b
    if n >= N:
        break
        
A.sort()
print(sum(A[-N:]))
# Judge status: Wrong Answer
n = int(input())
M = 10**9+7
sum = 1
for i in range(1,n):
  sum *= i%M
print(sum%M)
# Judge status: Accepted
n = int(input())
abc_list = [list(map(int, input().split())) for i in range(n)]
dp = [[0] * 3 for i in range(n)]
dp[0] = [abc_list[0][0], abc_list[0][1], abc_list[0][2]]

for i in range(1, n):
    dp[i][0] = abc_list[i][0] + max(dp[i - 1][1], dp[i - 1][2])
    dp[i][1] = abc_list[i][1] + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = abc_list[i][2] + max(dp[i - 1][0], dp[i - 1][1])

print(max(dp[n - 1]))
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

a.sort()
a.append(0)
ans = 0
flag = True
for i in range(1,n+1):
    if a[i] == a[i-1]:
        flag = not flag
    else:
        if flag:
            ans += 1
        flag = True
    #print(flag)
    #print(a[i])
print(ans)
# Judge status: Accepted
S = input()

if S=="Sunny":
  print("Cloudy")
elif S=="Cloudy":
  print("Rainy")
else:
  print("Sunny")
# Judge status: Accepted
n = int(input())
abl = []
for _ in range(n):
   a,b = map(int,input().split())
   abl.append((a,b))

abl = reversed(abl)

ans = 0
for a,b in abl:
    a += ans
    if a % b != 0:
        ans += b - (a % b)

print(ans)
# Judge status: Accepted
ipt = input()
input_list = list(ipt)
if input_list[2] == input_list[3] and input_list[4] == input_list[5]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b=map(str,input().split())
if int(a+b)**0.5%1:
	print('No')
else:
	print('Yes')
# Judge status: Accepted
def resolve(S: int, W: int) -> str:
    if S <= W:
        return 'unsafe'
    else:
        return 'safe'

if __name__ == '__main__':
    S, W = map(int, input().split())
    res = resolve(S, W)
    print(res)
# Judge status: Wrong Answer
n , d = map(int, input().split())
count = 0

for i in range(n):
    if n > 2*d+1:
        count += 1
        n = n - 2*d+1
if n != 0:
    count += 1

print(count)
# Judge status: Accepted
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
list=[]
for hh in h:
  list.append(t-0.006*hh)
ans=[]
for l in list:
  ans.append(abs(a-l))
print(ans.index(min(ans))+1)
# Judge status: Accepted
def main():
    hoge = int(input())
    print(-(-hoge // 2))

if __name__ == '__main__':
    main()
# Judge status: Accepted
from itertools import accumulate

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

ans = a[-1]
for i in a:
    ans = min(ans,abs(2*i-a[-1]))
print(ans)
# Judge status: Accepted
import statistics
n = int(input())
A = [int(i) for i in input().split()]
A_list = []
ans_l,ans_h = 0,0
Min = 10**9

for i in range(n):
    A_list.append(A[i]-(i+1))

b_lowkey = statistics.median_low(A_list)
b_highkey = statistics.median_high(A_list)

for i in range(n):
    ans_l += abs(A_list[i]-b_lowkey)
    ans_h += abs(A_list[i]-b_highkey)
print(min(ans_l,ans_h))
# Judge status: Wrong Answer
from collections import deque
N, H = map(int, input().split())
a, b = [], []
for _ in range(N):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
a.sort()
b.sort()
maxa = a[-1]
que = deque(b)
cnt = 0
while H >= 0:
    if not que:
        cnt += -(-H//maxa)
        break
    maxb = que.pop()
    if maxb > maxa:
        cnt += 1
        H -= maxb
    else:
        cnt += -(-H//maxa)
        break
print(cnt)
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline

D = int(input())

print("Christmas" + " Eve" * (25 - D))
# Judge status: Accepted
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
def f(x):
    return x[0]-x[1]
def g(x):
    return x[0]+x[1]
ans = max(f(max(xy, key=f))-f(min(xy, key=f)),
          g(max(xy, key=g))-g(min(xy, key=g)),)
print(ans)
# Judge status: Accepted
N, X = map(int, input().split())
A = list(map(int, input().split()))

answer = 0
for i in range(N - 1):
  d = A[i] + A[i+1] - X
  if d <= 0:
    continue
  if d > A[i+1]:
    A[i] -= d - A[i+1]
    A[i+1] = 0
  else:
    A[i+1] -= d
  answer += d

#print(A)
print(answer)
# Judge status: Accepted
a,b,c,k = map(int, input().split())

ans=a-b
if k%2==1:
  ans=b-a
if ans > 10**18:
  print("Unfair")
else:
  print(ans)
# Judge status: Accepted
# aアリス　　　ｂボブ
a, b = map(int, input().split())
if a == b:
    print("Draw")
elif a == 1:
    print("Alice")
elif b == 1:
    print("Bob")
elif a < b:
    print("Bob")
elif b < a:
    print("Alice")
# Judge status: Accepted
n,a,b=map(int,input().split())
m=10**9+7
def c(x,r=1):
 for i in range(x):r=r*(n-i)*pow(i+1,m-2,m)%m
 return r
print((pow(2,n,m)-1-c(a)-c(b))%m)
# Judge status: Accepted
if __name__ == '__main__':
	#全探索
	S = input()
	s_len = len(S)
	s1 = {"A","C","G","T"}
	
	m_len = 0
	for x in range(s_len):
		for y in range(x+1,s_len+1):
			s2 = set(S[x:y])
			s_union =  s1.union(s2)
			if len(s_union) == 4:
				m_len = max(m_len,len(S[x:y]))
	print(m_len)
# Judge status: Accepted
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0

for a in range(n):
    for b in range(a):
        over_c = l[a] + l[b]
        over_c_index = bisect.bisect_left(l,over_c)
        quantity = over_c_index - a - 1
        ans += max(quantity,0)
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(str, input().split()))
total = 0
for i in A:
    total += int(i)
    

for i in range(M):
    count = 0
    b, c = map(str, input().split())
    
    for n in A:
        if n == b:
            count += 1
    total += (int(c)-int(b))*count
        
       
print(total)
# Judge status: Accepted
H, A = map(int, input().split())
print(H // A if H % A == 0 else H // A + 1)
# Judge status: Accepted
ans = []
n = int(input())
w = list(map(int, input().split()))

for t in range(n):
    s1 = []
    s2 = []
    for i in range(len(w)):
        if t >= i:
            s1.append(w[i])
        elif t < i:
            s2.append(w[i])
    ans.append(abs(sum(s1) - sum(s2)))

print(min(ans))
# Judge status: Accepted
x,y = map(int, input().split())

cnt = 0
while x <= y:
    x *= 2
    cnt += 1
print(cnt)
# Judge status: Accepted
S = input()

if S[-1] == 's':
  P = S + "es"
else:
  P = S + "s"

print(P)
# Judge status: Accepted
def main(X):
    list753 = [3,5,7]
    return 'YES' if X in list753 else 'NO'
        
X = int(input())
print(main(X))
# Judge status: Accepted
a, b, c = sorted(map(int, input().split()))
print(("No", "Yes")[a + b == c])
# Judge status: Accepted
N = int(input())
s = []

for i in range(N):
  s.append(int(input()))
  
S = sum(s)

if S%10 != 0:
  print(S)
else:
  b = True
  for j in range(N):
    if  s[j]%10 == 0:
      continue
    else:
      b = False
  if b:
    print(0)
  else:
    s.sort()
    for k in range(N):
      if s[k]%10 != 0:
        print(S-s[k])
        break
# Judge status: Accepted
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


n,k=input_list()

ans=0

for i in range(1,n+1):
    cal=math.ceil(math.log(k/i,2))
    cal=max(0,cal)
    ans+=(1/2)**(cal)

print(ans/n)
# Judge status: Accepted
N, M = map(int, input().split())
print(abs(N-2)*abs(M-2))
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))
count = 0
count2 = 0
for i in a:
    if i%4==0:
        count += 1
    elif i%2==0:
        count2 += 1

if count2 <= 1:
    count2 = 0

if count >= N//2-count2:
    print('Yes')
else:
    print('No')

2228187
# Judge status: Wrong Answer
def f(x):
    sum = 0
    for i in str(x):
        sum += int(i)
    return sum
n = int(input())
aim = 1000000000
for i in range(2,n-1):
    sum = f(i)+f(n-i)
    aim = min(aim,sum)
print(aim)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * (n+1)
for i in range(n):
    cnt[a[i]] += 1
cntl = sorted(cnt)
print(sum(cntl[:-k]))
# Judge status: Accepted
s = input()
print('yes' if len(list(s)) == len(set(s)) else'no')
# Judge status: Wrong Answer
s=input()
l=len(s)
k=int(input())
z=''
for i in range(l):
  t=123-ord(s[i])
  if t<=k:
    z+='a'
    k-=t
  else:
    z+=s[i]
k=k%26
z=z[:l-1]+chr((ord(z[l-1])+k)%26)
print(z)
# Judge status: Accepted
n = int(input())

if n == 1:
    ans = 1
else:
    i = 0
    now = 1
    while now < n:
        now *= 2
        i+=1
    if now > n:
        ans = now//2
    else:
        ans = now
print(ans)
# Judge status: Wrong Answer
import math

n = int(input())
result = 0
for k in range(1, n+1):
    result += k


print(result)
# Judge status: Accepted
import sys
from collections import deque


reverse = 0
S = deque(list(input()))
q = int(input())

for query in sys.stdin:
    if query[0] == '1':
        reverse = 1 - reverse
        continue

    _, f, c = query.split()
    f = int(f)
    action = (reverse + f) % 2
    if action:
        S.appendleft(c)
    else:
        S.append(c)

if reverse:
    S.reverse()

print(''.join(S))