Problem:
 Score : 400 points    Problem Statement Caracal is fighting with a monster.  The health of the monster is H .  Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:   If the monster's health is 1 , it drops to 0 .  If the monster's health, X , is greater than 1 , that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor .   ( \lfloor r \rfloor denotes the greatest integer not exceeding r .)  Caracal wins when the healths of all existing monsters become 0 or below.  Find the minimum number of attacks Caracal needs to make before winning.      Constraints  1 \leq H \leq 10^{12}  All values in input are integers.         Input Input is given from Standard Input in the following format:  H       Output Find the minimum number of attacks Caracal needs to make before winning.        Sample Input 1 2      Sample Output 1 3  When Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1 .  Then, Caracal can attack each of these new monsters once and win with a total of three attacks.       Sample Input 2 4      Sample Output 2 7       Sample Input 3 1000000000000      Sample Output 3 1099511627775

Solution (Python):
H=int(input())
number=1
numbers=[]
while number<pow(10,12):
    numbers.append(number)
    number*=2
numbers=[a for a in numbers if a <=H]
print(sum(numbers))

Solution (Python):
def bin(n):
  k = 0
  while(n >= 2**k):
    k += 1
  return 2**k-1
H = int(input())
print(bin(H))

Solution (Python):
h = int(input())
mon_num = 1
count = 1
while True:
    if h <= 1:
        break
    else:
        h //= 2
        mon_num *= 2
        count += mon_num
print(count)

Solution (Python):
h=int(input())
count=1
while h!=1:
    h=h//2
    count+=1
print(2**count-1)

Solution (Python):
import sys

def s(d, i=1, a=1):
    a += i*2
    if d <= 1:
        return a
    return s(d-1,i=i*2, a=a)

H = int(input())
if H==1:
    print(1)
    sys.exit()
count = 0

while True:
    count += 1
    
    H = H // 2
    
    if H <= 1:
        break

print(s(count))

Solution (Python):
n = int(input())
for i in reversed(range(40)):
    if n >= 2 **i:
        print(2**(i+1)-1)
        break

Solution (Python):
def hel(h):
  if h==1:
    return 1
  else:
    return (2*hel(int(h/2))+1)
health=int(input())
print(hel(health))

Solution (Python):
H = int(input())

def dfs(h):
    if h == 1:
        return 1
    else:
        return 2 * dfs(h//2) + 1
ans = dfs(H)
print(ans)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

h = ni()
ct = 0
while h > 0:
    h //= 2
    ct = ct * 2 + 1
print(ct)

Solution (Python):
H = int(input())
res = 0
x = 1
while H > 0:
  res += x
  x *= 2
  H //= 2
print(res)

Solution (Python):
H = int(input())

def dfs(h):
    if h == 1:
        return 1
    else:
        return 2 * dfs(h//2) + 1

ans = dfs(H)
print(ans)

Solution (Python):
H=int(input())

enemy=1
ans=0
while H>0:
    ans+=enemy
    H//=2
    enemy*=2
print(ans)

Solution (Python):
H = int(input())
cnt = 0
while H > 1:
    H = H//2
    cnt = cnt+1
print (2**(cnt+1)-1)

Solution (Python):
import math

hp = int(input())
log2 = int(math.log2(hp))
print(2 ** (log2 + 1) - 1)

Solution (Python):
H = int(input())

def attackNum(H):
    if H == 1:
        return 1
    else:
        return 2 * attackNum(H // 2) + 1

print(attackNum(H))

Solution (Python):
h = int(input())
c = 1
i = 0
while h > 1:
    h //= 2
    c *= 2
    i += c
print(i + 1)

Solution (Python):
H = int(input())
cnt = 0
ans = 0
while H > 0:
    H = H//2
    ans += 2**cnt
    cnt += 1
    
print(ans)

Solution (Python):
H = int(input())
cnt = 0
ans = 0
while H > 1:
    H = H//2
    cnt += 1
for i in range(1, cnt+1):
    ans += 2**i
print(ans+1)

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int):
    from math import ceil
    from functools import lru_cache

    @lru_cache(None)
    def f(n: int):
        if 0 < n <= 1:
            return 1
        
        return 1 + f((n//2)) + f((n//2))

    print(f(H))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    solve(H)

if __name__ == '__main__':
    main()

Solution (Python):
h = int(input())
enemy_cnt = 1
ans = 0
while h:
    h //= 2
    ans += enemy_cnt
    enemy_cnt *= 2
print(ans)

Solution (Python):
H = int(input())
ans = 0
num = 1
while H:
    ans += num
    H //= 2
    num *= 2
print(ans)

Solution (Python):
def main():

    H = int(input())
    count=0

    while H>0:
        H = H//2
        count = count + 1

    print(sum(2**i for i in range(count)))


if __name__ == '__main__':
    main()

Solution (Python):
H=int(input())
def total(H):
    if H < 1:
        return 0

    return 2*total(H/2)+1
print(total(H))

Solution (Python):








h = int(input())

ans = 0
b = 1
while h > 0:
    ans += b
    b *= 2
    h //= 2

print(ans)

Solution (Python):
h = int(input())
c = 0
k = 1
while h > 0:
  h = h//2
  c += k
  k = k*2
print(c)

Solution (Python):
h=int(input())
n=0

while True:
  if 2**n<=h<2**(n+1):
    ans=sum([2**i for i in range(n+1)])
    print(ans)
    break
  else:
    n+=1

Solution (Python):
h = int(input())

c = 0
while True:
    if  2**c <= h < 2**(c+1):
        print(sum([2**n for n in range(c+1)]))
        break
    else:
        c += 1

Solution (Python):
H = int(input())

def attack(x):
    if x > 1:
        return attack(int(x/2)) * 2 + 1
    else:
        return 1
        
print(attack(H))

Solution (Python):
H = int(input())

num = 1
ans = 0
while H >= 1:
    ans += num
    num *= 2
    H //= 2

print(ans)

Solution (Python):
H = int(input())
ans = 0
while H >= 2:
  H = H//2
  ans += 1
print(2**(ans+1)-1)

Solution (Python):
H=int(input())
a=0
t=1
while H:
    H//=2
    a+=t
    t*=2
print(a)

Solution (Python):
H = int(input())
attack = 0
while(H != 1):
    H = H // 2
    attack = attack +1


kill = 0

for i in range(attack+1):
    kill = kill + 2**i
    

print(kill)

Solution (Python):
H = int(input())
m = 1
cnt = 0
if H == 1:
  print(1)
  exit()
while True:
  if H < m:
    print(m  - 1)
    exit()
  m *= 2
  cnt += 1

Solution (Python):
from collections import deque
n = int(input())
i, cnt = 2, 1
ans = deque([1])
while(1):
  if n<i:
    break
  ans.append(i)
  i = i*2
  
  cnt += 1

print(sum(ans))

Solution (Python):
h = int(input())
def solve(result, hp):
    if hp==1:
        return result+1
    result = solve(result, hp//2)*2 + 1
    return result

print(solve(0, h))

Solution (Python):
H = int(input())


def _attack_num(x):
    if x == 1:
        return 1
    else:
        return 2 * _attack_num(x // 2) + 1

print(_attack_num(H))

Solution (Python):
"""メモ
n = 0になるまで2で割った回数
answer = sum(2^0 + 2^1 + 2^2 + 2^3 + ... + 2^(n-1))
"""


def sum_2_expo(cnt):
    ans = 0
    for i in range(cnt):
        ans += 2 ** i
    return ans


H = int(input())
cnt = 0
while H != 0:
    H //= 2
    cnt += 1

print(sum_2_expo(cnt))

Solution (Python):
H = int(input())
count = 0
for x in range(H):
    if H < 2 ** count:
        break
    else:
        count += 1
print(2 ** count - 1)

Solution (Python):
def calc_at(H):
    
    num = 0
    n = 0
    while True:
        n_beki2 = 2 ** n
        if H < n_beki2:
            break
        num += n_beki2
        n += 1
    return num


H = int(input())
print(calc_at(H))

Solution (Python):
n = int(input())
ans = 0
gen = 0
while n >= 1:
  ans += 2**gen
  gen += 1
  n = n // 2
print(ans)

Solution (Python):
h = int(input())
ans = 0
bin_h = format(h,'b')
l = len(bin_h)
for i in range(l):
    ans += 2**i
print(ans)

Solution (Python):
h=int(input())
n=1
while h>=n:
    n*=2
print(n-1)

Solution (Python):
import math
H = int(input())
def res(H):
  if H == 1:
    return 1
  return res(int(H/2))*2+1
print(res(H))

Solution (Python):
h=int(input())




import math
ans=1
count=1
while h!=1:
    count*=2
    ans+=count
    h=math.floor(h/2)
    
print(ans)

Solution (Python):
h=int(input())
for i  in range(41):
  if h<pow(2,i):
    print(pow(2,i)-1)
    break

Solution (Python):
H = int(input())


def f(n):
    if n == 1:
        return 1
    else:
        return 1 + f(n // 2) * 2


print(f(H))

Solution (Python):
H = int(input())

attack_num = 0
n = 0

while H >= 1:
  n += 1
  attack_num += 2 ** (n -1)
  H //= 2

print(attack_num)

Solution (Python):
def re(H):
    if H == 1:
        return 1
    else:
        return re(H//2)*2+1

H = int(input())
print(re(H))

Solution (Python):
h = int(input())

ans = 0
count = 0
while h>=1:
    count += 1
    ans += 2 ** (count-1)
    h //= 2
print(ans)

Solution (Python):
import math

def get_count(H, count) :

    if (H == 1) :
        return 1


    return 2 * get_count(H // 2, count) + 1

def main() :
    H = int(input())
    c = get_count(H,0)
    print(c)

main()

Solution (Python):
H=int(input())
N=1
C=0
while H>1:
    H//=2
    C+=N
    N*=2
print(N+C)

Solution (Python):
h = int(input())
hh = h
kaisuu = 0
while h>1:
    h //= 2
    kaisuu += 1

if hh==1:
    print(1)
else:
    ans = 1
    for i in range(1, kaisuu+1):
        ans += 2**i
    print(ans)

Solution (Python):
H = int(input())
t = H
depth = 0
ans = 0
while t >= 1:
    ans += 2**depth
    t //= 2
    depth += 1
print(ans)

Solution (Python):
h=int(input())
cnt=0
num=1

for i in range(10**9):
  if h==1:
    cnt+=num
    break
  else:
    h=int(h/2)
    cnt+=num
    num*=2
print(cnt)

Solution (Python):
def resolve():
    import math
    h = int(input())
    logh = int(math.log(h,2))
    rlist = []
    cum = 1
    for i in range(40):
        rlist.append(cum)
        cum = cum*2+1
    print(rlist[logh])
resolve()

Solution (Python):
def f(h):
    if h == 1:
        return 1
    return 2 * f(int(h/2)) + 1

h = int(input())

ans = f(h)

print(ans)

Solution (Python):
import math
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    a = int(math.log2(h)) +1
    
    ans = (1-2**a)//(1-2)
    print(ans)

if __name__=='__main__':
    main()

Solution (Python):

h = int(input())






























def solve(acc, count, ans):
    if acc // 2 == 0:
        return ans + (2 ** (count - 1))

    return solve(acc // 2, count + 1, ans + (2 ** (count - 1)))


print(solve(h, 1, 0))

Solution (Python):
import math
print(2**(math.floor(math.log2(int(input())))+1)-1)

Solution (Python):
import math
print(2 ** (math.floor(math.log2(int(input()))) + 1) - 1)

Solution (Python):
from sys import stdin

cnt=0

def recursive(H):
    
    global cnt
    cnt=cnt+1
    if H==1:
        return
    H=int(H/2)
    
    recursive(H)
    

H= int(input())

recursive(H)
print((2 ** cnt)-1)

Solution (Python):
h = int(input())
i = 0
c = 1
while h >= c:
    c *= 2
    i += 1
i -= 1
ans = 1
x = 2
for n in range(i):
    ans += x
    x *= 2
print(ans)

Solution (Python):
H = int(input())
attackcount = 0
mon = 1
while H >= 1:
    attackcount = attackcount + mon
    H = H // 2
    mon = mon * 2

print(attackcount)

Solution (Python):
h=int(input())

flag = True
vital=h
count=0

while flag:
	if vital == 1:
		flag=False
	else:
		vital = int(vital/2)
		count+=1

AAA=0

for i in range(count+1):
	AAA += 2**i

print(AAA)

Solution (Python):

import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    H = II()
    from math import log2,floor
    print( 2**(floor(log2(H))+1)-1)

if __name__ == '__main__':
    main()

Solution (Python):
H = int(input())

memo = {}
memo[1] = 1

def f(h):
    if h in memo:
        return memo[h]
    v = 2 * f(h // 2) + 1
    memo[h] = v
    return v

print(f(H))

Solution (Python):
H = int(input())
def dub(H):
    if(H ==1):
        return 1
    else:
        newH = H//2
        return 2*dub(newH)+1
        
print(dub(H))

Solution (Python):
H = int(input())
ene = 1
count = 0
while H >= 1:
  H //= 2
  count += ene
  ene *= 2
print(count)

Solution (Python):
H = int(input())
count = 0
while H > 1:
  if H%2 == 0:
    H = H//2
    count += 1
  else:
    H = (H-1)//2
    count += 1
print(2**count -1 + 2**count)

Solution (Python):
H = int(input())
binH = list(bin(H))
binans = 0

for i in range(len(binH) - 2):
    binans += 1 * 10 ** i
    
binans = str(binans)

print(int(binans, 2))

Solution (Python):
def solve(H,i):
    if H ==1:
        return i
    else:
        return solve(H//2,i*2+1)
    
H=int(input())

ans = solve(H,1)
print(ans)

Solution (Python):
H = int(input())
K = [1]
for i in range(100):
    K.append(K[i]*2+1)
    if pow(2,i+1)>H:
        print(K[i])
        break

Solution (Python):
h = int(input())
count = 0

while h >= 1:
  count += 1
  h /= 2
print((1 << count) -1)

Solution (Python):
def attack(hit_point):
    if hit_point == 1:
        return 1
    return 2 * attack(hit_point//2) + 1

print(attack(int(input())))

Solution (Python):
import math
h = int(input())
ans = 2**(math.floor(math.log2(h))+1)-1
print(ans)

Solution (Python):
h = int(input())

n = 0
while h >= 1:
    n += 1
    h /= 2
print((1 << n) - 1)

Solution (Python):
import numpy as np
def f(h):
    if h<=1:
        return 1
    else:
        return (2*f(h//2)+1)

h=int(input())
print(f(h))

Solution (Python):
def aaa(hp, times=0):
    if hp == 1:
        return times
    else:
        return aaa(hp//2, times+1)

h = int(input())
ans = 0
for i in range(aaa(h) + 1):
    ans += 2 ** i
print(ans)

Solution (Python):
H = int(input())
result = 0
i = 0
while H != 0:
  result += 1 * 2 ** i
  H = H // 2
  i += 1
print(result)

Solution (Python):
def caracal(h):
    if h == 1:
        return 1
    else:
        return caracal(h//2)*2+1

h = int(input())

print(caracal(h))

Solution (Python):
print(2**(len(bin(int(input()))[2:]))-1)

Solution (Python):
h = int(input())
a = 1
sum = 0

while(h > 0):
    sum += a
    a *= 2
    h = h // 2

print(sum)

Solution (Python):
H=int(input())
cnt=0
while H>1:
    H = H//2
    cnt+=1

ans=0
for i in range(cnt+1):
    ans+=2**i
print(ans)

Solution (Python):
n = int(input())
a = 1
ans = 1
while True:
    a *= 2
    if a > n:
        break
    ans = ans*2 + 1

print(ans)

Solution (Python):
print(2**(len(bin(int(input())))-2)-1)

Solution (Python):

h=int(input())

for i in range(50):
    if 2**i <= h and h<2**(i+1):
        ans=i
        break
print(2**(i+1)-1)

Solution (Python):
h=int(input())
ans=0
c=1
while h:
    h//=2
    ans+=c
    c*=2
print(ans)

Solution (Python):
import math
H = int(input())

def attack(h):
    if h == 1:
        return 1
    elif h == 2:
        return 3
    else:
        return 1 + 2 * attack(int(h/2))
ans = attack(H)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    H = int(input())
    ans = 0
    while H > 0:
        ans += 1
        H //= 2
    print(pow(2, ans) - 1)

if __name__ == "__main__":
    main()

Solution (Python):
import math
print(pow(2,int(math.log(int(input()), 2)//1)+1)-1)

Solution (Python):
x=int(input())
def hit(h):
    if h==1: return 1
    elif h>1:
        return 2*hit(h//2)+1
print(hit(x))

Solution (Python):
from math import floor

h = int(input())
hSum = 0
for i in range(10**12):
    hSum += 2 ** i
    h = floor(h/2)
    if h == 0:
        break

print(hSum)

Solution (Python):
h = int(input())

i = 0
while 2**i <= h:
    i += 1

count = 0
for j in range(i):
    count += 2**j

print(count)

Solution (Python):

H = int(input())
A = 1
ans = 1
while A <= H:
    A = A * 2
    ans += A
ans -= A
print(ans)

Solution (Python):
from sys import stdin

def main():
    input = stdin.readline

    H = int(input())

    ans = 0
    bai = 0

    while H >= bai*2:
        if(bai == 0):
            bai = 1
        else:
            bai = bai * 2
        ans = ans + bai
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
H = int(input())

cnt = 0
n = 1
while H >= 2:
  H = H//2
  cnt += n
  n *= 2
cnt += n  
print(cnt)

Solution (Python):
h=int(input())
def dfs(n):
  if n==1:
    return 1
  return 1+2*(dfs(n//2))

print(dfs(h))

Solution (Python):
import math

ans = {1:1}

h = int(input())

def mons(n):
  if n in ans:
    return ans[n]
  else:
    return 1+ 2*mons(math.floor(n/2))

print(mons(h))

Solution (Python):
h = input().strip()
h = int(h)
count = 0
sum = 0

while h > 0:
  h //= 2
  count += 1
  
for v in range(count):
  sum += pow(2, v)
  
print(sum)

Solution (Python):
from math import log
n=int(input())
n=2**(int(log(n,2)))
print(2*n-1)

Solution (Python):
H = int(input())

def solve(H):
    if H <= 1:
        return 1
    else:
        return solve(H // 2) * 2 + 1

print(solve(H))

Solution (Python):
H=int(input())
time=1
while True:
    if H>1:
        H=H//2
        time+=1
    else:
        break
        
print(2**time-1)

Solution (Python):
H = int(input())
ans = 0
count2 = 0
while H/2 == H//2:
    count2 += 1
    H //= 2
    
ans += 2**count2 - 1



countOdd = 0
while H > 1:
    countOdd += 1
    H //= 2
   
ans += (2**count2) * (2**(countOdd+1) -1)

print(ans)

Solution (Python):
hp = int(input())
n_monster = 1
atk_cnt = 0
while hp > 1:
    atk_cnt += n_monster
    n_monster *= 2
    hp //= 2

atk_cnt += n_monster
print(atk_cnt)

Solution (Python):
h = int(input())

i=0
ans=0
while h>=2:
    h = h//2
    ans += 2 ** i
    i += 1
print(ans + 2**i)

Solution (Python):


h = int(input())

if h == 1:
	h = 0
	count = 1
else:
	count = 0
	for i in range(0,100000):
		h = h//2
		
		count += 2**i
		if h == 0:
			break

print(count)

Solution (Python):
h = int(input())
count = 0
while h != 1:
    h = h // 2
    count += 1
ans = [2 ** i for i in range(count + 1)]
print(sum(ans))

Solution (Python):
import math
h = int(input())
count = 0
while h != 1:
    h = math.floor(h / 2)
    count += 1
ans = [2 ** i for i in range(count + 1)]
print(sum(ans))

Solution (Python):
h = int(input())

def count(hp):
    if hp == 1:
        return 1
    else:
        return 2 * count(int(hp/2)) + 1
print(count(h))

Solution (Python):
count = 0
atack = 0
n = int(input())
while n >= 1:
    n = n // 2
    count += 1

for i in range(count):
    atack += 2**i

print(atack)

Solution (Python):
import math

h = int(input())

print(2**(math.floor(math.log2(h))+1)-1)

Solution (Python):
H = int(input())

num = 1
cnt = 0
flg = 0
while flg == 0:
  if H > 1 :
    H = H//2
    cnt += 1*num
    num *= 2
  else:
    flg = 1

print(cnt + num)

Solution (Python):
H = int(input())
i = 0
count = 0
while H > 1:
    H = H // 2
    count += pow(2, i)
    i += 1
print(count + pow(2, i))

Solution (Python):
H = int(input())

E = []

while H>0:
    E.append(H)
    H //= 2
print(pow(2, (len(E))) - 1)

Solution (Python):
h = int(input())

import math
ans = pow(2, math.floor(math.log(h, 2))+1) - 1
print(ans)

Solution (Python):
H = int(input())

def calc(X):
  if X==1:
    return 1
  else:
    return 1+2*calc(X//2)
  
print(calc(H))

Solution (Python):
h = int(input())
count = 0
while h>=1:
    h = h/2
    count += 1
print(2**(count)-1)

Solution (Python):
H = int(input())


i=1
while True:
    A=2**i
    if H==A:
        jo=i
        break
        
    elif H<A:
        jo=i-1
        break
    i+=1

result=0
for j in range(0,jo+1):
    result=result+2**j
print(result)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N = int(input())

def rec(n):
  if n==1:
    return 1
  return rec(n//2)*2 + 1
print(rec(N))

Solution (Python):
def calc(a):
  if a > 1:
    return 2 * calc(a // 2) + 1
  else:
    return 1

a = int(input())
i = 0
print(calc(a))

Solution (Python):
H=int(input())
ans=0
num=1
while H>0:
  ans+=num
  num*=2
  H//=2
print(ans)

Solution (Python):



from heapq import *






H=int(input())
count=1
while H>=2:
    H//=2
    count*=2
count*=2
count-=1
print(count)

Solution (Python):
h=int(input())
d=dict()
def f(n):
  if n==1:
    return 1
  else:
    if n//2 in d.keys():
      return 1+2*d[n//2]
    else:
      return 1+2*f(n//2)
print(f(h))

Solution (Python):
print(2**(len(bin(int(input())))-2)-1)

Solution (Python):
import math
print(2**(math.ceil(math.log2(float(input())+1)))-1)

Solution (Python):
A = int(input())
ans = 1
while A != 0:
    A = A//2
    ans = ans * 2
    if A==0:
        ans = ans - 1
        
print(ans)

Solution (Python):
h = int(input())

cnt = 0

while h > 1:
    h = h//2
    
    cnt += 1
    
if(h == 1):
    sm = 2**(cnt+1) -1
else:
    sm = 2**cnt - 1


print(sm)

Solution (Python):
h=int(input())
n=1
k=0
while(h>1):
  k+=n
  n*=2
  h//=2
k+=n
print(k)

Solution (Python):
h=int(input())

i=1
ans=0
while h>0:
   h//=2
   ans+=i
   i*=2
print(ans)

Solution (Python):
h=int(input())
n=0
while h>0:
    h=h//2
    n+=1
print(2**n-1)

Solution (Python):
h = int(input())

count = 0
while h > 0:
    h //= 2
    count += 1
    
n = [1]*count
for i in range(count):
    if i > 0:
        n[i] = n[i-1]*2
        
print(sum(n))

Solution (Python):
h = int(input())

i = 0
while True:
    if 2**i > h:
        break
    i += 1
 
print(2**i -1)

Solution (Python):
h = int(input())

i = 0
while True:
    if 2**i > h:
        break
    i += 1

ans = 2**i -1
print(ans)

Solution (Python):
import math

H = int(input())
max_ = math.ceil(math.log2(10**12))
dp = [1]*max_
for i in range(1,max_):
    dp[i] = dp[i-1]*2+1
print(dp[math.floor(math.log2(H))])

Solution (Python):
import numpy as np
H = int(input())
 
print(2 ** (int(np.log2(H)) + 1) - 1)

Solution (Python):
h=int(input())
ans=1
plus=1
while h>1:
    h//=2
    plus*=2
    ans+=plus
print(ans)

Solution (Python):
H = int(input())
ans = 0
num_monster = 1
while(H >= 1):
    H //= 2
    ans += num_monster
    num_monster *= 2
print(ans)

Solution (Python):
H, ans, n = int(input()), 0, 1
while H != 0:
    ans, n, H = ans + n, n * 2, H // 2
print(ans)

Solution (Python):
def solve():
    dp = {}

    def execute(h):
        if h == 1:
            return 1
        if h in dp:
            return dp[h]
        ans = 1 + execute(h // 2) * 2
        dp[h] = ans
        return ans

    return execute


H = int(input())
solver = solve()
print(solver(H))

Solution (Python):
def attack(n):
    if n <= 1:
        return 1

    return 1 + attack(n // 2)*2


h = int(input())
count = attack(h)
print(count)

Solution (Python):
h = int(input())
ans = 0
cut = 1
while h > 0:
    ans += cut
    cut = cut << 1
    h = h >> 1
print(ans)

Solution (Python):
H = int(input())

memo = {}
memo['0'] = 0
memo['1'] = 1

def dp(arg):
    key = str(arg)
    if memo.setdefault(key, None) != None: return memo[key]
    ret = 1 + 2 * dp(arg // 2)
    memo[key] = ret
    return ret

print(dp(H))

Solution (Python):
import math
h=int(input())
k=math.ceil(math.log2(h))
if k==math.log2(h):
  print(2**(k+1)-1)
else:
  print(2**k-1)

Solution (Python):
h = int(input())

def f(num):
    if num == 1:
        return 1
    else:
        return f(num//2) * 2 + 1

print(f(h))

Solution (Python):
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]

def solve():
    return rec(N)

def rec(n):
    if n == 1:
        return 1
    return 2 * rec(n // 2) + 1

if __name__ == "__main__":
    print(solve())

Solution (Python):
def recursion(x):
    if x == 0:
        return 0
    return 1+recursion(x//2)*2

print(recursion(int(input())))

Solution (Python):



from math import *
from copy import *
from string import *				
from random import *				
from sys import stdin
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
from collections import defaultdict 

'''

'''

def solve(x):
	lvls = floor(log(x,2)) + 1
	ans = ((2**lvls - 1))
	return int(ans)
	

N = int(stdin.readline())
ans = solve(N)
print(ans)

Solution (Python):
print(2**(len(bin(int(input())))-2)-1)

Solution (Python):
h = int(input())
a = len(bin(h))-2
print(2**a-1)

Solution (Python):
h =int(input())

count = 0

def countMethod(n):
    global count
    if n==1:
        return

    count+=1

    countMethod(n//2)

countMethod(h)

print(2**(count+1)-1)

Solution (Python):
H = int(input())

ans = 0
count = 0
while H != 0:
    ans += pow(2, count)
    H = H // 2
    count += 1
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def attack(H):
    if H == 1:
        return 1
    else:
        return 1 + 2 * attack(H//2)

H = int(input())
print(attack(H))

Solution (Python):
import math

h = int(input())
x = h
ans = 0
cnt = 0

while x != 0:
    x = x // 2
    ans += 2 ** cnt
    cnt += 1

print(ans)

Solution (Python):
h = int(input())

i = 1
while True:
    if h == 1:
        break
    else:
        h = h // 2
        i+=1

print(2**i-1)

Solution (Python):


import math

a = input()


b = math.log(float(a), 2)

ans = sum([pow(2, i) for i in range(1, int(b) + 1)]) + 1

print(ans)

Solution (Python):
import sys
import math

input = sys.stdin.readline

H = int(input())

if H == 1:
    print(1)
    exit()
    
if H % 2 == 1:
    H -= 1

layer = int(math.log2(H)) + 1

print(2**layer - 1)

Solution (Python):

def monster(X):
    global cnt
    if(X!=0):
        cnt+=1
        monster(X//2)
        




import sys
H=int(input())
cnt=0
if(H==1):
    print('1')
else:
    i=2
    j=3
    tmp=1
    while (True):
        if(i <= H and j >= H):
            print(j)
            sys.exit()
        i*=2
        j=j*2+1

Solution (Python):
H = int(input())

def dfs(h):
    if h == 1: return 1
    return 1 + dfs(int(h/2)) * 2

print(dfs(H))

Solution (Python):
import math
H = int(input())

T = int(math.log2(H))
print(int((2**T - 1) + 2 ** (T)))

Solution (Python):
import math

H = int(input())

h = math.ceil(math.log2(H))
if math.log2(H) == math.ceil(math.log2(H)):
  ans = pow(2,h+1)-1
else:
  ans = pow(2,h)-1
    
print(ans)

Solution (Python):
h=int(input())

ans=0
i=0
while h>0:
   ans+=2**i
   h=h//2
   i+=1
print(ans)

Solution (Python):
h=int(input())
cnt=0
while h>1:
	if h%2==0:
		cnt+=1
		h/=2
	else:
		h-=1
num=[2**i for i in range(cnt+1)]
print(sum(num))

Solution (Python):
def find(x):
    if x==1:
        return 1
    if x==0:
        return 0
    y=x//2
    return  1+2*find(y)
    
print(find(int(input())))

Solution (Python):
h=int(input())
s=[2**i-1 for i in range(1,100)]
tmp=[2**i for i in range(100)]

for i in range(100):
  if tmp[i]>h:
    print(s[i-1])
    break

Solution (Python):
def slove(h,counter):
    if h == 1:
        return counter + 1
    else:
        return 2 * slove(h//2,counter) + 1

h = int(input())

print(slove(h,0))

Solution (Python):
import sys
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    n = getN()
    po = 1
    while(n > 1):
        po += 1
        n = n//2

    print(2**po - 1)


if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Solution (Python):
H = int(input())
n = len(bin(H)) - 3
N = [2 ** i for i in range(n + 1)]
print(sum(N))

Solution (Python):
import math

H = int(input())

log2H = int(math.log2(H))

ans = 0
for i in range(log2H+1):
    ans += 2 ** i
    
print(ans)

Solution (Python):
h=int(input())

def cnt(a):
    if a==1:
        return 1
    else:
        return cnt(a//2)*2+1

print(cnt(h))

Solution (Python):
H = int(input())
cnt = 0
num_monster = 1

while H > 1:
  H = H // 2
  cnt = cnt + num_monster
  num_monster = num_monster * 2

cnt += num_monster

print(cnt)

Solution (Python):
n=int(input())
k=n
count=0
while k>1:
  k=k//2
  count+=1
print(2**(count+1)-1)

Solution (Python):
H = int(input())


def f(X):
    if X < 2:
        return X
    return f(int(X / 2)) * 2 + 1


print(f(H))

Solution (Python):
h = int(input())

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

Solution (Python):

h = int(input())
ans =0
mos = []
i = 1
while h > 0:
    mos.append(i)
    h = h//2
    i *=2
    
    
print(sum(mos))

Solution (Python):
h = int(input())
ans = 1

for i in range(1, h):
    ans += 2 ** i
    h = h // 2
    if h == 1:
        break

print(ans)

Solution (Python):
H = int(input())
mns = 1
cnt = 0
while H > 1:
  cnt += mns
  mns *= 2
  H = H // 2 + (H % 2 > 1)
print(cnt + mns)

Solution (Python):
h = input()
cache = {1:1}
def foo(h):
    if h not in cache:
        cache[h] = 1 + foo(h/2) * 2
    return cache[h]

print foo(h)

Solution (Python):
import numpy
h=int(input())
p=int(numpy.log2(h))
print(2**(p+1)-1)

Solution (Python):
h = int(input())
count = 0


while h >= 2:
    h //= 2
    count += 1

ans = 2 ** (count + 1) - 1

print(ans)

Solution (Python):
def f(x):
    if x == 1:
        return 1
    return 2*f(int(x/2))+1

h = input()
h = int(h)
print(f(h))

Solution (Python):
def f(x):
    if x == 1:
        return 1
    else:
        return 2*f(int(x/2))+1

h = input()
h = int(h)
print(f(h))

Solution (Python):
h = int(input())
ans = 0




s = [0]
for i in range(41):
    s[i] = 2**i
    s.append(s[i])


for i in range(41):
    if h >= s[i]:
        ans += s[i]
    else:
        break

print(ans)

Solution (Python):
H = int(input())
e = 1
h = H
while h != 1:
    h = h // 2
    e += 1

print(2 ** e - 1)

Solution (Python):
def f(H):
    if H == 1:
        return 1
    if H > 0:
        return 2 * f(int(H/2)) + 1

H = input()
H = int(H)
ans = f(H)
print(ans)

Solution (Python):
def f(h):
  if h==1:
    return 1
  else:
    return f(h//2)*2+1
  
print(f(int(input())))

Solution (Python):
import math
H = int(input())

depth = 0
junction = 0
while H != 1:
    H = math.floor(H/2)
    junction += 2 ** depth
    depth += 1

print(junction + 2 ** depth)

Solution (Python):
h = int(input())

def rec(h):
    if h == 1:
        return 1
    else:
        return 1 + rec(h // 2) * 2

print(rec(h))

Solution (Python):
def kurakaru(h):
    if h == 1:
        return 1
    elif h > 1:
        return 1 + 2 * kurakaru(h//2)
h = int(input())
print(kurakaru(h))

Solution (Python):
n=int(input())
for i in range(100):
  if 2**i<=n<2**(i+1):
    print(2**(i+1)-1)

Solution (Python):
H = int(input())
a = 0
while H>1:
    a+=1
    H//=2

print(2**(a+1)-1)

Solution (Python):
H = int(input())
count = 0
H_num = 1
while True:
    count += H_num
    H = int(H/2)
    if H == 0:
        break
    H_num *= 2
print(count)