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())
attackcnt = 0
monstercnt = 1
def monster(h, m, a):
    if h == 1:
        return 0,0,a+m
    else:
        return monster(int((h/2)),2*m,a+m)
a, b, c = monster(H,monstercnt,attackcnt)
print(c)

Solution (Python):
H = int(input())
now = 1
for i in range(1,100):
  if now <= H <= now*2-1:
    print(2**i-1)
    break
  else:
    now *= 2

Solution (Python):
n = int(input())
s = 1
t = 0
while s <= n:
  s = s*2
  t += 1
print(2**t-1)

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

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

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

print(ans)

Solution (Python):

import sys


def solve(H: int):
    if H == 1:
        print(1)
        return
    i = 2
    c = 3
    while True:
        i *= 2
        if i > H:
            print(c)
            break
        c = c * 2 + 1


    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())
ii = 1
while H != 1:
    ii += 1
    H = H//2
print(2**ii-1)

Solution (Python):
def myfunc(N):
	if(N  <= 1):
		return 1
	return 2 * myfunc(int(N/2)) + 1

if __name__ == "__main__":
	N = int(input())
	print(myfunc(N))

Solution (Python):
h = int(input())
count = 0
for i in range(40):
    count += 2**i
    if h >= 2 ** i and h < 2 ** (i+1):
        break
print(count)

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

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

Solution (Python):
import math
H = int(input())
l = math.log(H,2)
ll = math.floor(l)+1
ans = 2 ** ll -1
print(ans)

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

cnt = 0
num = 1
while h > 0:
    cnt += num
    h = h // 2
    num *= 2
print(cnt)

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

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

print(cal(h))

Solution (Python):
h = int(input())
sumn = 0
i,k = 0,1
while k <= h:
    sumn+=k
    i+=1
    k = 2**i
    
print(sumn)

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

for i in range(10**12):
  if 2**i <= h < 2**(i+1):
    ans = 2**(i+1)-1
    print(ans)
    exit()

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

Solution (Python):


def main():
    N = 0
    H = int(input())
    ans = 0

    while (True):
        H //= 2
        if H == 0:
            break
        N += 1

    for i in range(N + 1):
        ans += pow(2, i)

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def abc153d_caracal_vs_monster():
    h = int(input())
    cnt = 0
    result = 0
    while h > 0:
        h = h//2
        result += pow(2, cnt)
        cnt += 1
    print(result)
abc153d_caracal_vs_monster()

Solution (Python):
import math

h = int(input())
atk = 0
enemy = 1

while True:
    if h > 1:
        h = math.floor(int(h/2))
        atk += enemy
        enemy *= 2
    elif h == 1:
        atk += enemy
        break

print(atk)

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

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
from functools import reduce

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


if __name__ == "__main__":
    main()

Solution (Python):
import math

H = int(input())
ans = 0
num = 0

while True:
    ans += 2**num   
    if H == 1:
        print(ans)
        break
    else:
        H = math.floor(H/2)
        num += 1

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

while(h > 1):
  count += 1
  h = int(h/2)

print(2**count - 1)

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

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

Solution (Python):
import math

def main():
    H = {int(input()): 1}
    ans = 0
    while True:
        new_H = {}
        for h, freq in H.items():
            ans += freq
            if h > 1:
                new_H[h // 2] = 2 * freq
        if len(new_H) == 0:
            break
        else:
            H = new_H
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

while hp:
    hp //= 2
    n += 1

print(2**n-1)

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

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

def main():
    mod=10**9+7
    H=I()
    ans=0
    
    def f(x):
        if x==0:
            return 0
        return f(x//2)*2 +1
    
    print(f(H))
        

main()

Solution (Python):

H = int(input())
h = H
count = 1
total_count = count
while h > 1:
  count *= 2
  total_count += count
  h //= 2
print(total_count)

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

Solution (Python):

import sys
input=sys.stdin.readline

def main():
    enemy_hp = int(input())
    enemy_count=1
    attack_count=1

    if enemy_hp==1:
        print(1)
        exit()
    else:
        while enemy_hp >1:
            enemy_hp = int(enemy_hp/2)
            enemy_count*=2
            attack_count+=enemy_count
            
    print(attack_count)

if __name__=="__main__":
    main()

Solution (Python):

H = int(input())

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

ans = getAns(H)

print(ans)

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

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

cnt = 0
ans = 0

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

print(ans+1)

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

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

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

list=[]
u=1
while u<=t:
    list.append(u)
    u=u+1

z=0
for i in list:
    z=z+2**(i-1)

print(str(z+s))

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

cnt = 0
res = 0

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

print(res+1)

Solution (Python):
import sys
import copy
import math
import itertools

H = int(input())
cnt = 0
for i in range(int(math.log2(H))+1):
    cnt+=2**i
print(cnt)

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

i = 0
while True:
  if H < 2 ** i:
    n = i
    break
  i += 1

print(2**n -1)

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

H = int(input())
cnt = 1
ans = 0

while True:
    if 2**cnt > H:
        cnt -= 1
        break
    elif 2**cnt == H:
        break
    else:
        cnt += 1

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

Solution (Python):
import math

h = int(input())
n = math.floor(math.log2(h)) + 1

print(2 ** n - 1)

Solution (Python):

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

    H = int(input())

    print(solve(H))


if __name__ == '__main__':
    main()

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

Solution (Python):

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import math

h = int(input())
l = int(math.log(h, 2))
p = (2**l)*2-1
print(p)

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

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

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

Solution (Python):
H = int(input())
for i in range(0, 10**20 + 1):
  if 2**i <= H < 2 ** (i + 1):
    break
print(2 ** (i + 1) - 1)

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

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

Solution (Python):
import numpy as np
H=int(input())
c=0
while H!=0:
  c+=1
  H=H//2

print(2**c-1)

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

Solution (Python):



def solve(H: int):
    n = 1
    attack = 0
    while H > 1:
        attack += n
        H = H // 2
        n *= 2
    attack += n
    return attack


def main():
    H = int(input())
    answer = solve(H)
    print(answer)


if __name__ == "__main__":
    main()

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

while H>0:
    H = int(H//2)
    ans += count
    count *= 2
    
print(ans)

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

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

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    h = I()
    num = 1
    ans = 0
    while h>1:
        h//=2
        ans += num
        num*=2
    ans += num
    print(ans)
main()

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

if H == 1:
  print(1)
  exit(0)

import math as m
n = m.floor(m.log2(H))+1
ans = (2**n) - 1

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(1000000)
def rec(n):
    if n == 1: 
        return 1
    return rec(n//2)*2+1

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

Solution (Python):
from sys import setrecursionlimit

setrecursionlimit(1000000)

H = int(input())


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


print(f(H))

Solution (Python):
import math
h = int(input())
l = 1

while (h != 1):
    h = math.floor(h / 2)
    l += 1
ans = 0

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

Solution (Python):

def main():
    h = int(input())
    cnt = 0
    while(h>0):
        h //= 2
        cnt += 1
    x = 0
    for i in range(cnt):
        x = x * 2 +1
    print(x)
    


if __name__ == "__main__":
    main()

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

cnt = 0
while h != 1:
    h //= 2
    cnt += 1
t = 1
ans = 0
for i in range(cnt+1):
    ans += t
    t *= 2
print(ans)

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

ans = 1
if H != 1:
    h = H
    for i in range(1, 40):
        if int(h/2) >= 2:

            ans += 2**i
            h = int(h/2)
        else:

            ans += 2**i
            break

print(ans)

Solution (Python):
H = int(input())
for i in range(0, 40):
  if 2**i <= H < 2**(i+1):
    H = 2 ** i
    break
ans = 0
for k in range(0, i+1):
  ans += 2**k
print(ans)

Solution (Python):

H = int(input())

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

print(rec(H))

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

Solution (Python):
H = int(input())
SUM = 0
cn = 1

if H == 1:
    print(1)
    exit()

for i in range(10000):
    H = H // 2
    cn = cn + 1
    if H == 1:
        break

for i in range(cn):
    SUM = SUM + (2**i)
    
print(SUM)

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

Solution (Python):
h = int(input())
for i in range(100):
    if 2**i > h:
        print(2**i - 1)
        exit()

Solution (Python):
import bisect
import numpy


H = int(input())

ans = 1
HP = 2
tmp = 1
while True:
    if H < HP:
        break
    else:
        tmp *= 2
        ans += tmp
        HP *= 2


print(ans)

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

def attack(h):
    if h == 1:
        return 0
    r = 2
    h //= 2
    ans = 2
    while h > 1:
        h //= 2
        r *= 2
        ans += r
    return ans
    
    
print(1 + attack(H))

Solution (Python):
import sys
H=int(input())
a = 0
while   True:
    H=int(H/2)
    a=a+1
    
    if  H==0:
        print(2**a-1) 
        sys.exit()

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

Solution (Python):
H = int(input())
Ans = 0
n = 0
while True:
    if H != 1:
        H = H//2
        Ans += 2**n
        n += 1
    else:
        Ans += 2**n
        break
print(Ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)

H = int(input())

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

Solution (Python):


h = int(input())

def f(h):
    if h > 1:
        return 2*f(h//2)+1
    else:
        return 1

print(f(h))

Solution (Python):


h = int(input())

ans = 0 
n = 1 
while n <= h:
    ans += n
    n *= 2

print(ans)

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

i = 1
cnt = 0

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

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

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

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

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

Solution (Python):






H = int(input())









































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

Solution (Python):
import  math

def pow(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

H = int(input())


print(pow(2,int(math.log2(H))+1)-1)

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

if H == 1:
    print(2**(cnt+1)-1)

else:
    print(2**cnt-1)

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

cnt=0

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

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

Solution (Python):

import sys
def input():
    return sys.stdin.readline()[:-1]

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

    ans = 0
    n = 1
    for i in range(10**12):
        if H == 1:
            ans += n
            print(ans)
            exit()
        ans += n
        n *= 2
        H = int(H/2)


if __name__ == '__main__':
    main()

Solution (Python):
a=int(input())
import math
total=0
total2=1
while True:
    if a>1:
        a=a//2
        total+=total2
        total2=total2*2
    elif a==1:
        print(total+total2)
        break

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

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

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

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

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

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

cnt = 0

while True:
    H //= 2
    cnt += 1

    if H == 0:
        break

print(2**cnt-1)

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

print(cnt)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    cur = 1
    cnt = 1

    while 2 * cur <= H:
        cur *= 2
        cnt *= 2
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):



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

Solution (Python):
import math


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

    counter = 0
    multiple = 1

    while True:
        if h == 1:
            counter += multiple
            break
        else:
            h = math.floor(h/2)
            counter += multiple
            multiple *= 2

    print(counter)


if __name__ == "__main__":
    main()

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

Solution (Python):









import os
import sys




def main():
    H = int(input())
    mul = 0
    while H != 1:
        mul += 1
        H //= 2
    print(2**(mul+1)-1)

if __name__ == "__main__":
    main()

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

import math

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

print(caracal(H))

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


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

    ans = f(h)

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    h = int(input())
    num = 1
    ans = 1

    while True:  
        num *= 2
        if h < num:
            break
        elif h == num:
            ans = 2 * ans + 1
            break
        ans = 2 * ans + 1

    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import math, copy
h=int(input())

cnt=0
a=copy.copy(h)
while a>1:
    a=math.ceil(a/2)
    cnt+=1

if h==2**(cnt):
    print(2**(cnt+1)+-1)
else:
    print(2**(cnt)+-1)

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

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

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

if h == 1:
    ans += n_enemy

print(ans)

Solution (Python):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

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

if __name__=='__main__':
    h = I()
    print(solve(h))

Solution (Python):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    l = [1, 2, 4, 8, 16, 
        32, 64, 128, 256, 512,
        1024, 2048, 4096, 8192, 16384, 
        32768, 65536, 131072, 262144, 524288, 
        1048576, 2097152, 4194304, 8388608, 16777216, 
        33554432, 67108864, 134217728, 268435456, 536870912, 
        1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 
        34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 
        1099511627776]
    c = 0
    while l[c]<h and l[c+1]<=h:
        c += 1
    print(2*l[c]-1)
    return

if __name__=='__main__':
    h = I()
    solve()

Solution (Python):

def f(H):
  return 2*f(H//2)+1 if H>1 else 1

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

Solution (Python):
N=int(input())
count = 0
sum = 0
while N != 0:
  count += 2**sum
  sum += 1
  N = int(N/2)
print(count)

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

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

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

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

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

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

Solution (Python):

H = int(input())

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

print(rec(H))

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

while h != 1:
  h = h//2
  n += 1
for i in range(n + 1):
  ans = ans + 2 ** i
print(ans)

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

x=0
while True:
    x+=1
    if 2**x>H:
        x-=1
        break

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

print(ans)

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

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

while(H > 0):
    cnt *= 2
    H //= 2

print(cnt - 1)

Solution (Python):
import os, sys, re, math

memo = {}
def attack(h):
    result = memo.get(h)
    if result:
        return result

    result = 1
    if h > 1:
        result += attack(h // 2) * 2
    memo[h] = result
    return result

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

Solution (Python):
import os, sys, re, math

memo = {}
def attack(h):
    result = memo.get(h)
    if result:
        return result
    if h == 1:
        result = 1
    else:
        result = 1 + attack(h // 2) * 2
    memo[h] = result
    return result

H = int(input())

print(attack(H))

Solution (Python):
h = int(input())
cnt,ex = 0,1
while h!=0:
  h = h//2
  cnt += ex
  ex *= 2
print(cnt)

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

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

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

Solution (Python):
H = int(input())
cnt = 0
ans = 0

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

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

print(ans)

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

sum = 0
i = 0
while H > 0:
    i += 1
    hits = 2**(i-1)
    sum += hits
    if H == 1:
        H = 0
    else:
        H //= 2

print(sum)

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

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

ans+=1*cnt

print(ans)

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








import math
def helper(h):
    if h ==1:
        return 1
    return 1 + 2 * helper(math.floor(h/2))
print(helper(H))

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
ans = 0
tmp = 1
while n > 0:
    n //= 2
    ans += tmp
    tmp *= 2
print(ans)

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

Solution (Python):
H=int(input())
A=1
while H>=A:
    A*=2
print(A-1)

Solution (Python):
h = int(input())
cnt = -1

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

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

print(ans)

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

power = 0
while True:
  if 2**power <= h < 2**(power+1):
    break
  else:
    power += 1
    
layer = power + 1
ans = int(2**layer) - 1
print(ans)

Solution (Python):
import sys
import numpy as np
import math as mt

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

n = int(readline())
cnt = 1
while n != 1:
  n = n//2
  cnt += 1

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

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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

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


def main():
    solve()


if __name__ == '__main__':
    main()

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

pw = 1
cnt = 0
while True:
    pw *= 2
    if pw > H:
        break
    cnt += 1

print(pw - 1)

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

print(atk(H))

Solution (Python):
h = [int(input())]
a = 1
while(True):
    if h[0] < 1:
        break
    h = list(map(lambda x: x / 2, h))
    a = a * 2
print(a - 1)

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

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

    if h == 1:
        minimum = 1
    else:
        if h % 2 == 1:
            h -= 1

        minimum = 0
        power = 0
        while True:
            minimum += 2 ** power
            power += 1

            if 2 ** power > h:
                break

    print(minimum)


if __name__ == '__main__':
    main()

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

tmp=math.log2(h)

print(2**(int(tmp+1))-1)

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

Solution (Python):
H = int(input())
num = {}
lis = [H]

h = H
while h > 1:
    h //= 2
    num[h] = 0
    lis = [h] + lis

num[1] = 1

for n in lis[1:]:
    num[n] = 2*num[n//2] + 1

print(num[H])

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

Solution (Python):
from math import log2

print(2 ** int(log2(int(input())) + 1) - 1)

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

print(attack(h))

Solution (Python):

H = int(input())

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

print(attack(H))

Solution (Python):
from math import floor

H = int(input())

ans = 0
r = H
n = 0
while not (r == 1):
    n += 1
    ans += 2 ** n
    r = floor(r / 2)

ans += 1

print(ans)

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

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

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

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

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

cnt = 0
def attack(hp, cnt):
    cnt += 1
    if hp == 1:
        return cnt

    cnt += attack(hp//2, 0) * 2
    return cnt

print(attack(H, cnt))

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

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

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

layer = 1
atack_cnt = 1

while True:
    if H == 1:
        print(atack_cnt)
        exit()
    
    elif H > 1:
        H = int(H/2)
        atack_cnt += layer*2
        layer *= 2

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

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

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


if a == 1:
    print("1")
else:
  for i in range(114514):
    a = a // 2
    b = b + 1
    if a == 1:
      break
    else:
      pass
  print(2 ** b - 1)

Solution (Python):
import sys

H = int(next(sys.stdin.buffer))

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

print(ans)

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

ans = 0
cnt = 0
while True:
    ans += 2 ** cnt
    if H == 1:
        break
    H = H//2
    cnt += 1

print(ans)

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

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")



def main():
    H = int(input())
    ans = 0
    i = 0
    while(H >= 1):
        ans += 2**i
        H /= 2
        i += 1

    print(ans)
    

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=0
b=0
while n!=0:
    n=n//2
    a+=2**b
    b+=1
print(a)

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

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

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

H = int(input())

print(kougeki(H))

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


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