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())
dig=len(format(h, 'b'))
print(2**dig-1)

Solution (Python):
import math
import sys
h = int(sys.stdin.readline().rstrip())
k = math.floor(math.log2(h))
print(2 ** (k + 1) - 1)

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

Solution (Python):
import math

h = int(input())
n = int(math.log(h, 2))
print(int((1-2**(n+1))/(1-2)))

Solution (Python):
H = int(input())
count = 0
ans = 1

if H == 1:
    print(1)
else:
    while H != 1:
        H = int(H/2)
        count += 1

    for _ in range(count):
        ans *= 2
        ans += 1

    print(ans)

Solution (Python):
h = int(input())
cnt = 1
s = 0
while True:
    s += cnt
    if h == 1:
        print(s)
        break
    h = h//2
    cnt *= 2

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

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

Solution (Python):
import math
import fractions

if __name__ == '__main__':
    h = int(input())
    n = math.floor(math.log2(h))
    print(2 ** (n + 1) - 1)

Solution (Python):
h = int(input())
h = str(format(h, 'b'))
print(2**len(h)-1)

Solution (Python):
h = int(input())
h = str(format(h, 'b'))
print(2**len(h)-1)

Solution (Python):
H = input().split()
H = int(H[0])

answer = 0
hp = 1
while hp <= H:
    answer = answer * 2 + 1
    hp *= 2
else:
    print(answer)

Solution (Python):
def main(h):
    if h == 1:
        return 1
    else:
        s = h//2
        return main(s)*2

if __name__ == "__main__":
    h = int(input())
    print(main(h)*2-1)

Solution (Python):

n = int(input())
if(n == 0):
    printf("0\n");
else:
    attacks = 1;
    moves = 0;
    while(n > 0):
        moves += attacks;
        attacks = attacks << 1;
        n = n >> 1;
    print(moves)

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

Solution (Python):
import math

n = int(input())
print((2 ** (int(math.log(n, 2)) + 1) - 1))

Solution (Python):
import math

H = float(input())
count = 1
i = 1

while True:
    H = math.floor(H/2)

    if H==0:
        break
    else:
        count = count + 2**i

    i += 1

print(count)

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

count = 0
p = 0

while h > 0:
    count += 2 ** p
    p += 1
    h //= 2

print(count)

Solution (Python):


n=int(input())
cnt=0
while n:
    cnt+=1
    n=n//2 
print(pow(2,cnt)-1)

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

ans = 1
while H > 0:
    if H == 1:
        ans *= 2
        print(ans-1)
        break
    else:
        H //= 2
        ans *= 2

Solution (Python):
def main():
    h  = int(input())
    sum = 0
    tmp = 1
    while(h!=0):
        sum += tmp
        tmp *= 2
        h = h//2
    print(sum)
    return 

if __name__=="__main__":
    main()

Solution (Python):
n = int(input())
import sys

total = 0 

dicts = {}
dicts[1] = 1 
dicts[2] = 3 
dicts[0] = 0 
if n == 1:
    print(1)
    sys.exit()

if n == 2:
    print(3)
    sys.exit()
 
def dfs(jk):  
    global total
    global dicts
    if jk in dicts:
        return dicts[jk]
    
    if jk not in dicts:
        half = int(jk //2 )
        new = dfs(half) + dfs(half) + 1
        dicts[jk] = new 
        return new 
    
dfs(n)

print(dicts[n])

Solution (Python):

H = int(input())
for i in range(41):
    if (2**i-1 >= H):
        print (2**i-1)
        break

Solution (Python):
import numpy as np

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

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

Solution (Python):
import math

monster_hp = int(input())
attack_count = 0

def attack_count_calc(monster_hp):
    if monster_hp == 1:                
        return attack_count + 1
    return attack_count + (2 * attack_count_calc(monster_hp//2) + 1)

print(attack_count_calc(monster_hp))

Solution (Python):

H = int(input())
for i in range(50):
    if (2**i-1 >= H):
        print (2**i-1)
        break

Solution (Python):
h = int(input())
l_goukei = list()
counter = 0
while(sum(l_goukei) < h):
    if len(l_goukei) == 0:
        l_goukei.append(1)
    else:
        l_goukei.append(l_goukei[-1] * 2)
print(sum(l_goukei))

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

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

Solution (Python):
S=int(input())
ANS=0
if S <= 1:
  print(1)
else:
  ANS=1
  while 2**ANS <= S:
    ANS += 1
  
  print(2**ANS-1)

Solution (Python):
S=int(input())
ANS=0
if S <= 1:
  print(1)
else:
  ANS=1
  while 2**ANS <= S:
    ANS += 1
  
  print(2**ANS-1)

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

Solution (Python):

import sys





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

def solve(H: int):
    print(count(H))



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())
count = 0
while(H>0):
    H=H//2
    count+=1

print(2**count - 1)

Solution (Python):
import math

integrationEnemy = int(input())
sqrtCount = 0
harf = 10

while True:
    if harf == 1:
        sqrtCount += 1
        break
    elif harf == 0:
        break
    else:
        sqrtCount += 1

    if sqrtCount == 1:
        harf = math.floor(integrationEnemy / 2)
    else:
        harf = math.floor(harf / 2)

print(2**(sqrtCount)- 1)

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

h_bin = bin(h)
l_bin = len(h_bin)

print(2**(l_bin-2) - 1)

Solution (Python):
import math
h = int(input())
ans = 0
for i in range(0, math.floor(math.log2(h)) + 1):
  ans += 2 ** i
print(ans)

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

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

count = 0
while True:
    if a < 2:
        break
    else:
        count += 1
        a = a/2
ans = 2**(count+1)-1
print(ans)

Solution (Python):
H = int(input())
print(2 ** H.bit_length() - 1)

Solution (Python):
h = int(input())
def bisec(i):
    if i == 1:
        return 1
    else:
        return 2*bisec(i//2)
print(bisec(h)*2-1)

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

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

print(sum)

Solution (Python):
H = int(input())
A = []
A.append((H, 1))
ans = 0
while len(A) > 0:
    h, c = A[0]
    A.pop(0)
    ans += c
    if h != 1:
        A.append((h//2, c*2))
print(ans)

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

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

height = 0
for i in range(10**12):
    if H == 1:
        height = i+1
        break
    H = H//2

print(2**height-1)

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

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

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

print(saiki(h))

Solution (Python):
def f(n):
	if n in memo:
		return memo[n]
	if n <= 1:
		return n
	memo[n] = 2 * f(n // 2) + 1
	return memo[n]

memo = {}
n = int(input())
print(f(n))

Solution (Python):
import math



























def calc_rep_num(H):
    H_temp = H
    rep = 0
    while not(H_temp == 1):
        H_temp = math.floor(H_temp/2)
        rep += 1
    return rep

def calc_Attack_num(rep):
    Attack_num = (1-2**(rep))/(1-2)+2**rep
    return int(Attack_num)


    

H = int(input())

rep = calc_rep_num(H)

Attack_num = calc_Attack_num(rep)

print(Attack_num)

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

n = 0

while h >= 2 ** n:
    n += 1

print(2 ** n - 1)

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

def attack(a):
    if a >1:
        return 2 * attack(a//2) +1
    elif a == 1:
        return 1
print(attack(h))

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

Solution (Python):
def solve(h):
    res = 0
    a = 1
    while h > 0:
        res += a
        h //= 2
        a *= 2
    return res

assert solve(2) == 3
assert solve(4) == 7
assert solve(1000000000000) == 1099511627775
h = int(input())
print(solve(h))

Solution (Python):
H = int(input())
a = 0
for i in range(0, 10**7):
    if H == 1:
        a = i
        break
    H = H // 2
ans = 0
for i in range(0, a+1):
    ans += 2**i
print(ans)

Solution (Python):
n = int(input())
a = []
cur = 1
while cur <= n:
  a.append(cur)
  cur *= 2
print(sum(a))

Solution (Python):
import math
H = int(input())
ans = 0
cnt = 0
for i in range(10000000000):
 H = H//2
 if H == 0 :
  cnt = i+1
  break
for i in range(cnt):
 ans = ans + 2**i
print(ans)

Solution (Python):
h = int(input())
ans = 0
while True:
    if h == 1:
        break
    elif h == 2:
        ans += 1
        break
    else:
        h //= 2
        ans += 1
print(2**(ans+1)-1)

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

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

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines







def main():
	h=int(input())
	
	cnt=0
	p=1
	while h>0:
		cnt+=p
		h//=2
		p*=2
	
	print(cnt)
	
	
	
	
	

if __name__ == "__main__":
	main()

Solution (Python):
h = int(input())
i = 0
cn = 0

while(h):
    h = h//2
    cn += 2**i
    i += 1
    
print(cn)

Solution (Python):
from fractions import math

n=int(input())
s=(int(math.log(n, 2)))

l=[1]
for i in range(s):
  l.append(2*l[-1]+1)
print(l[-1])

Solution (Python):


def rec(x):
    if x == 1:
        return 1

    return 2 * rec(x // 2) + 1


def main():
    from sys import setrecursionlimit

    setrecursionlimit(10 ** 7)

    n = int(input())
    print(rec(n))


if __name__ == '__main__':
    main()

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

Solution (Python):
inp = list(map(int, input().split()))
H = inp[0]

flag = False
vv = []
vv.append(H)
sum = 0

a = 1
for count in range(1,10000000000000000000000):
    if vv[len(vv)-1] != 1:
        sum += a
        a = a*2
        vv.append(int(vv[len(vv)-1] // 2))
    else:
        sum += a
        break

print(sum)

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

Solution (Python):



def main():
  h = int(input())
  count = 0
  while True:
    h //= 2
    count += 1
    if h == 0:
      break
  print(2**count - 1)

if __name__=='__main__':
  main()

Solution (Python):
import math

def getOneAttack(hp):
    if hp <= 1:
        return 1
    remainHp = math.floor(hp/2)
    return 1 + getOneAttack(remainHp) * 2

eneHp = int(input())
count = getOneAttack(eneHp)

print("{}".format(count))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()

print(2**len("{:b}".format(H))-1)

Solution (Python):


import math


def main():
    h = int(input())
    x = 2**int(math.log2(h))
    print(2 * x - 1)


if __name__ == "__main__":
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()

print(sum([2**i for i in range(len("{:b}".format(H)))]))

Solution (Python):
import math

def main():
    a = int(input())
    print(mama(a,0,0))

def mama(hp,num,sum):
    sum = sum + 2**num
    num = num + 1
    if hp <= 1:
        return sum

    hp = hp//2
    return mama(hp,num,sum)


if __name__ == "__main__":
    main()

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

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

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

print(ans)

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

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

print(attack(H))

Solution (Python):
import sys

def main():

    

    h = int(input()
            )
    print(func(h) - 1)

def func(h):
    
    if h < 1:
        return 1
    else:
        return 2 * func(h // 2) 


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from functools import lru_cache


@lru_cache(maxsize=None)
def alg_memoization_recursion(n):
    if n == 1:
        return 1
    else:
        return alg_memoization_recursion(n // 2) + alg_memoization_recursion(n // 2) + 1


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h = int(input().rstrip('\n'))
    print(alg_memoization_recursion(h))


if __name__ == '__main__':
    solve()

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

H = int(input())
print(caracal(H))

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

times = (2**n) - 1
print(times)

Solution (Python):
def atack(x, count):
    if(x == 1):
        return count+1
    return 2 * atack(x // 2, count) + 1

print(atack(int(input()), 0))

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

Solution (Python):
H = int(input())
s = 1
while H!=0:
    H = divmod(H, 2)[0]
    s *= 2
s = s / 2
p = s - 1
print(int(s + p))

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

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

Solution (Python):

import numpy as np

H = int(input())
x = int(np.log2(H))
sum=0
for i in range(x+1):
    sum+=pow(2,i)
print(sum)

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

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

def main():
    N = int(input())
    def attack(x):
        if x == 1:
            return 1
        else:
            x //= 2
            return 2*attack(x)+1
            
    print(attack(N))
    
if __name__ == "__main__":
    main()

Solution (Python):
import math
h = int(input())
p = math.floor(math.log(h)/math.log(2))
print(2**(p+1)-1)

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

atk = 0
hp = H
ene = 1

while hp > 1:
    atk += ene
    hp = int(hp / 2)
    ene *= 2

atk += ene

print(atk)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000)

H = int(input())

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

print(f(H))

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

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

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


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


print(f(h))

Solution (Python):

import math



H = int(input())

count = 1
while (H > 1):
    count += 1
    H = H // 2

print (2 ** count - 1)

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

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

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

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

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

Solution (Python):
from math import floor


def f(N):
    if N == 1:
        return 1
    return f(floor(N / 2)) * 2 + 1


def main():
    N = int(input())
    print(f(N))


if __name__ == '__main__':
    main()

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

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

ans = 0
if h == 1:
    print(1)
    exit()


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

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

ans = 0
k = 1
while h:
    ans += k
    k *= 2
    h //= 2

print(ans)

Solution (Python):
h = int(input())
i = 2
while True:
  if i > h:
    print(i-1)
    break
  i*=2

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
H = int(read())
 
answer = 0
coef = 1
while H:
    answer += coef
    H //= 2
    coef *= 2
 
print(answer)

Solution (Python):
print~-2**input().bit_length()

Solution (Python):
import math
H=int(input())
ans=0
at=1
while(H>0):
    H=math.floor(H/2)
    ans=ans+at
    at=at*2
print(ans)

Solution (Python):
print(~-2**int(input()).bit_length())

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

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


print(rec(H))

Solution (Python):
print(2**(int(input()).bit_length())-1)

Solution (Python):
H = int(input())
ans = 1
while(ans<=H):
    ans *= 2
print(ans-1)

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

print(ans)

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

Solution (Python):
def solve():
    H = int(input())
    print(f(H))

def f(x):
    if x == 1:
        return 1

    return 2 * f(x//2) + 1

if __name__ == '__main__':
    solve()

Solution (Python):
from math import floor

cache = {}


def number_to_kill(h):
    if h == 1:
        return 1

    if h in cache:
        return cache[h]

    new_health = h // 2
    half_number = number_to_kill(new_health)
    res = 2 * half_number + 1
    cache[h] = res
    return res


h = int(input())
print(number_to_kill(h))

Solution (Python):
def solve(h):
    if h == 0:
        return 0
    ans = 2 * solve(h // 2) + 1
    return ans


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

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

cnt=0
result=0

while n>1:
  n=n//2
  result+=2**cnt
  cnt+=1

print(result+2**cnt)

Solution (Python):
import math
from sys import stdin
H = int(stdin.readline().rstrip())

def solve(h):
  if h == 1:
    return 1
  else:
    return 2*solve(math.floor(h/2))+1

print(solve(H))

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

Solution (Python):


def main():
    n = int(input())
    j = 0
    count = 1

    while n > 1:
        n //= 2
        j += 1
        count += 2 ** j

    print(count)


if __name__ == '__main__':
    main()

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

s = attack(int(input()))
print(s)

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

if __name__ == '__main__':
    H = int(input().rstrip())
    print(pow(2, int(math.log2(H))+1)-1)

Solution (Python):
import math

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

Solution (Python):
a = int(input())
def fibonaci(h):
    if h < 2:
        if h == 0:
            return 0
        return 1
    else:
        return (2*fibonaci(h/2) + 1)


print(fibonaci(a))

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

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

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

Solution (Python):
import math

H = int(input())

L = math.floor(math.log2(H))

sum = 0
for i in range(int(L)+1):
  sum += 2**i
  
print(sum)

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

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

Solution (Python):
import math
def rec(h,cnt):
  if h==1:
    return cnt+1
  else:
    c=math.floor(h/2)
    cnt+=(rec(c,cnt))*2
    return cnt+1
h=int(input())
print(rec(h,0))

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

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

n = 0
while h > 1:
    h //= 2
    n += 1

answer = 0
for i in range(n + 1):
    answer += 2**i

print(answer)

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

while h > 1:
  h = math.floor(h/2)
  count +=1
  

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

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


h = int(input())


print(f(h))

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

n = len(format(h, "b"))
print(2**n - 1)

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

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

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

ans = 0
base = 1

while H >= 1:

  ans += base
  base *= 2
  H /= 2
  
print(ans)

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

l = []
while h >= 1:
    l.append(h)
    h //= 2

print(2**len(l) - 1)

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

def calc(H):
  n = 1
  while H > 1:
    H = int(math.floor(H/2))
    n += 1
  print(2**(n)-1)
  
calc(H)

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

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

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

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

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

def res(HP):
    if HP == 0:
        return 0
    return res(HP//2) * 2 + 1
   
print(res(H))

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


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

print(attack(h))

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

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

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

while h>1:
  h = h // 2
  c = c*2
  ans += c

print(ans)

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

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

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

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

Solution (Python):
import math
h = int(input())
n = int(math.log2(h))
ans = 0
for i in range(n+1):
  ans += 2**i
print(ans)

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

ans = 1
total = 2
while total<=h:
  ans += total
  total = total * 2

print(ans)

Solution (Python):
import math
ans = 1
for _ in range(math.floor(math.log(int(input()), 2))):
    ans = ans * 2 + 1
print(ans)

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

print(ans)

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

Solution (Python):
h=int(input())
a,b=1,0
while h>0:
    b+=a
    a*=2
    h//=2
print(b)

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


import math

H = int(input())
print(battle(H))

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

count = 0

def dfs(h):
  if h == 1:
    return 1

  return dfs(h // 2) * 2 + 1

print(dfs(H))

Solution (Python):
import math

hp=int(input())

lim =math.floor(math.log2(hp))

sum=0

for i in range(lim+1):
    sum=sum+2**i

print(sum)

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

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

Solution (Python):
import heapq

H = int(input())

count = 0

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

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

h = int(input())
print(dfs(h))

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

t = 1
ans = 0

while (H > 0):
    ans += t
    H //= 2
    t *= 2

print(ans)

Solution (Python):

import math
H = int(input())

max_h = 10**12
n = 1

while H > 1:
    H //=  2
    n += 1

print((2**n)-1)

Solution (Python):
import math

H=int(input())
n=0
S=0

while H>0:
  
  if H>1:
    H=math.floor(H/2)
    n+=1
    S+=2**n

  if H==1:
    break

print(S+1)

Solution (Python):
import math
h=(input())

x=math.floor(math.log2(int(h)))
x=x+1
ans=1
for i in range(x):
    ans*=2

print(ans-1)

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

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

Solution (Python):
a=int(input())
count=0
s=0
while True:
  if a>1:
    a//=int(2)
    count+=1
    s+=2**count
  else:
    s+=1
    print(s)
    break

Solution (Python):
print(2**len(format(int(input()), "b"))-1)

Solution (Python):
import math
def solve(x):
  if x == 1:
    return 1
  elif x == 0:
    return 0
  else:
    return 2 * solve(math.floor(x/2)) + 1
x = int(input())
print(solve(x))

Solution (Python):
import sys

input = sys.stdin.readline

H = int(input())

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

print(f(H))

Solution (Python):
from sys import setrecursionlimit

setrecursionlimit(1000000)


H=int(input())
def monum(n):
    if n==1:
        return 1
    else:
        return 1+monum(n//2)*2
print(monum(H))

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

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

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

cnt = 0
total = 0
while H>0:
  H = H//2
  cnt += 1

total += 2**cnt

  
print(total-1)

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

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

while H >= 1:
  kaisu += 1
  if H > 1:
    H = H // 2
  else:
    break

ans = 0

for i in range(kaisu):
  ans = ans + 2**i

print(ans)

Solution (Python):
H = int(input())
count = 0
i = 0

while H >= 1:
	H = H//2
	i += 1
	count += 2**(i-1)

print(count)

Solution (Python):
a=int(input())
k=2
while a>=k:k*=2
print(k-1)

Solution (Python):
from math import log2
print(pow(2,int(log2(int(input()))) + 1) - 1)

Solution (Python):
import math

def caracal(h):
    if h == 1:
        return 1
    else:
        return 2*caracal(math.floor(h/2)) + 1

if __name__ == "__main__":
    h = int(input())
    print(caracal(h))

Solution (Python):

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


def solve(H: int):
    x = 0
    while H > 0:
        H -= 2 ** x
        x += 1

    ans = 0
    while x > 0:
        ans = 2*ans + 1
        x -= 1

    print(ans)

    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):

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


def solve(H: int):
    x = 0
    while H > 0:
        H -= 2 ** x
        x += 1

    ans = 0
    while x >= 0:
        ans = 2*ans + 1
        x -= 1

    print(ans//2)

    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):
import math
h = int(input())
hp = h
c = 0
ans = 0

while hp > 1:
    hp = math.floor(hp/2)
    c += 1
for i in range(0,c+1):
    ans += 2 ** i
print(ans)

Solution (Python):
print(2**int(input()).bit_length()-1)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(2000)
def IN(): return map(int,input().split())
ans = 0; mod = pow(10,9)+7
h=int(input())
def dfs(x):
  if x==1: return 1
  else: 
    return dfs(x//2)*2+1

print(dfs(h))

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

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

print(f(H))

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    H = int(input())

    c = 0
    while H > 0:
        c += 1
        if H < 1:
            H = 0
        else:
            H //= 2
    print(sum([2 ** i for i in range(c)]))

if __name__ == '__main__':
    main()

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

h = 0
while H != 1:
	H = int(H/2)
	h += 1
print(2**(h+1)-1)

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

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

temp = 1
p = 0

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

Solution (Python):

from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H=int(input())
cnt = 1
p = 1
import math
while H > 1:
    H = math.floor(H/2)
    cnt += 2 ** p
    p += 1
print(cnt)

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

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

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

Solution (Python):
def count_attack(hp):
    if hp == 1:
        return 1
    else:
        return count_attack(hp//2) * 2 + 1

h=int(input())
print(count_attack(h))

Solution (Python):


h = int(input())

tmp = h
ans = 1

while tmp != 0:
    ans *= 2
    tmp = tmp //2
        
print(ans-1)