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):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def f(x):
    if x==1:
        return 1
    elif x%2 == 0:
        return 1+2*f(x//2)
    else:
        return 1+2*f((x-1)//2)

h = inn()
print(f(h))

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

cnt = 0

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



print(2**cnt-1)

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

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

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

mons = 1
count = 0
while True:
    count += mons
    mons *= 2
    H //= 2
    if H == 0:
        break
print(count)

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

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

print(ans)

Solution (Python):
from collections import deque
h=int(input())
q=deque()
count=0
q.append(h)
while(len(q)>0):
    hi=q.popleft()
    if(hi==1):
        pass
    else:
        attacked_hi=hi//2
        q.append(attacked_hi)
    count+=1

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

Solution (Python):
import math

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

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

Solution (Python):
import sys
H = int(input())
i = 0
s = 1
while 1:
    if H <= 1:
        print(s)
        sys.exit()
    else :
        H //= 2
        i += 1
        s += (2 ** i)

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

result = 0
i = 1
while h > 0:
    h = h // 2
    result = result + i
    i *= 2

print(result)

Solution (Python):
from math import floor

h = int(input())
p = 0
c = 1

while h > 0:
    h=floor(h/2)
    p,c = p+c,c*2

print(p)

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

result = 0
i = 1
while h > 0:
    h = h // 2
    result = result + i
    i *= 2

print(result)

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

Solution (Python):
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


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


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


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

Solution (Python):
import math
import sys
h = int(input())
ans = 0
num = 0
if h == 1:
    print(1)
    sys.exit()
for i in range(41,0,-1):
    if 2**i <= h:
        num = 2**i
        rep = i
        
        break
for i in range(rep+1):
    ans += 2**i

print(ans)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) 

def LI(): return list(map(int, sys.stdin.readline().split()))

H = int(input())
"""
100
50 50
25 25 25 25
12 * 8
6 * 16
3 * 32
1 * 64
ans = 1 + 2 + 4 + 8 + 16 + 32 + 64
"""
x = 1
for i in range(41):
    x *= 2
    if H < x:
        k = i
        break

anss = [1]
for i in range(41):
    anss.append(anss[-1] * 2 + 1)
print(anss[k])

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

    if h == 0:
        break


print(ans)

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

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

bin_str = format(h, 'b')
keta=len(bin_str)

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

Solution (Python):
import math

H = int(input())

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

print(ans)

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

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

Solution (Python):
H = int(input())
result = 0
count = 0
while True:
    if H < 1:
        break
    result += pow(2, count)
    H //= 2
    count += 1

print(result)

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

Solution (Python):
import math
H = int(input())
ctr = 1
while H != 1:
	H //= 2
	ctr += 1
	
print(2 ** ctr - 1)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    H = INT()
    s = "{:b}".format(H)
    print(int(s[0] * len(s), 2))


if __name__ == '__main__':
    main()

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

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

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

ans = 0
cnt = 1
while H > 0:
  ans += cnt
  H = H >> 1
  cnt = cnt << 1
  
print(ans)

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

memo = dict()


def dfs(v):
    if v == 1:
        return 1
    elif v in memo:
        return memo[v]
    else:
        memo[v] = 2 * dfs(v // 2) + 1
        return memo[v]


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

    print(dfs(H))


if __name__ == '__main__':
    main()

Solution (Python):
from math import log2

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

    n = int(log2(H))

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    h=I()
    def nextPowerOf2(n): 
        p = 1
        if (n and not(n & (n - 1))):
            return n
        while (p < n) :
            p <<= 1
        return p
    if h==1:
        print(1)
    else:
        p = nextPowerOf2(h)
        if h==p:
            print(nextPowerOf2(h+1)-1)
        else:
            print(p-1)

if __name__ == "__main__":
    main()

Solution (Python):
import math
H = int(input())
cnt = 0
while H != 1:
    cnt += 1
    H = math.floor(H/2)
ans = 0
for i in range(cnt+1):
    ans += 2**i
print(ans)

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
h=ni()
t=int(math.log2(h))


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

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

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

result = attack(h)
print(result)

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

attack = 0
count = 1
HP = H

while HP != 1:
    attack += count
    count = count * 2
    HP = int(HP / 2)

attack = attack + count
print(attack)

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

h = int(input())

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

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

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

result = 0
i = 1
while h > 0:
    h = h // 2
    result = result + i
    i *= 2

print(result)

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

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

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

print(solve(H))

Solution (Python):


H = int(input())

for i in range(49):
    if 2**i <= H and H<2**(i+1):
        n = i
        break

ans = 2**(n+1)-1
print(ans)

Solution (Python):

H = int(input())

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


print(ans)

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

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

print(attack(h))

Solution (Python):


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

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

Solution (Python):
def d_caracal_vs_monster():
    H = int(input())
    exp = len(bin(H)) - 2
    return 2**exp - 1

print(d_caracal_vs_monster())

Solution (Python):
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush




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





def main():
    h = iin()
    ans = 0
    ch, ch1 = h, 1
    while ch*ch1 :
        ch //= 2
        ans += ch1
        ch1 *= 2

    print(ans)



            
        

        
main()

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

H=II()

cntEnem = 1
cntAtk = 0

while H:
    cntAtk += cntEnem
    cntEnem *= 2
    H //= 2

print(cntAtk)

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

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

ans = 0
for i in range(count + 1):
    ans += pow(2, i)
print(ans)

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

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

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

Solution (Python):
h=int(input())
import sys
sys.setrecursionlimit(10**5)
def ans(x):
    if x <= 1:
        return 1
    else:
        return ans(x//2)*2+1
print(ans(h))

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

Solution (Python):
h = int(input())
if h == 1:
    print(1)
    exit()
for i in range(1,2000):
    h //= 2
    if h == 1:break
ans = 2**(i+1)-1
print(ans)

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

Solution (Python):


H = int(input())

x = 0
a = 1

while H>0:
    x += a
    a *= 2
    H //= 2

print(x)

Solution (Python):
import math

h = int(input())
memo = [0]
cnt = 0

while h > 1:
    cnt += 1
    memo.append(cnt)
    h = math.floor(h / 2)

ans = 0
for i in range(len(memo)):
    ans += 2 ** memo[i]

print(ans)

Solution (Python):
from sys import stdin




def ii(): return int(stdin.readline())


def fi(): return float(stdin.readline())


def mi(): return map(int, stdin.readline().split())


def fmi(): return map(float, stdin.readline().split())


def li(): return list(mi())


def lsi():
    x=list(stdin.readline())
    x.pop()
    return x


def si(): return stdin.readline()


def sieve(x):
    a=[True]*(x+1)
    sq=floor(sqrt(x))
    for i in range(3, sq+1, 2):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]=False
    if x>1:
        p=[2]
    else:
        p=[]
    for i in range(3, x+1, 2):
        if a[i]:
            p.append(i)
    return p

pow=[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, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808]

n=ii()
p=0
for i in pow:
    if i>n:
        break
    p+=i
print(p)

Solution (Python):
h=int(input())
r=h
x=0
while h>1:
  h/=2
  x+=1
if r%(2**x)==0:
  ans=2**(x+1)-1
else:
  ans=2**x-1

print(ans)

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

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

ans = solve(H)
print(ans)

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

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

a = bin(h)
b = len(a)-2

print(2**b - 1)

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

checked = {}


def check_attack(h):
    if h == 1:
        checked[h] = 1
        return 1
    elif h in checked:
        return checked[h]
    else:
        k = 1 + 2 * check_attack(h//2)
        checked[h] = k
        return k

print(check_attack(h))

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

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

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

print(ans)

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

ans = 0
for i in range(len(n[2:])):
    ans += 2 ** i
    
print(ans)

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

import numpy as np

def solve(num):

    if num==1:
        return 1

    return 1+2 * solve(np.floor(num/2))

print(solve(h))

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

h = int(input())
print(bfs(h))

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

Solution (Python):


H = int(input())

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


print(attack(H))

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

H += 1
tmp = 1
ans = 0
i = 0
while H > tmp:
    tmp *= 2
    ans += 2**i
    i += 1
print(ans)

Solution (Python):



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

H = int(input())

count = attack(H)
print(count)

Solution (Python):
h=int(input())
n=len(bin(h))-2
ans=0
for i in range(n):
    ans+=2**i
print(ans)

Solution (Python):
from collections import deque
H = int(input())

q = deque()
q.append(H)
ans = 0
h = H
K = 0
while h > 1:
    h //= 2
    K += 1

print(sum([2 ** k for k in range(K + 1)]))

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



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

print(2**count-1)

Solution (Python):
H = int(input())
i = 0
while 2**i < H:
  i += 1
if 2**i != H:
  i -= 1
ans = 0
j = 0
while j <= i:
  ans += 2**j
  j += 1
print(ans)

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

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

print(F(H))

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

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

    divided = H
    cnt = 0
    while divided != 1:
        divided //= 2
        cnt += 1
    
    ans = 0
    for i in range(cnt+1):
        ans += 2 ** i

    print(ans)

if __name__ == '__main__':
    solve()

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

flag = False
n = 0

while flag == False:
    if 2**n <= h < 2**(n+1):
        flag = True
    else:
        n += 1
print(2**(n+1)-1)

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

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

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

H = int(input())
k = 0

for i in range(40+1):
    a = 2**i
    if H<a:
        k = i - 1
        break
cnt = 0
for i in range(k+1):
    cnt += 2**i
print(cnt)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False

def main():
    H = I()
    ans = 0
    c = 0
    h = H

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

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import math
H = int(input())
count = 1
i = 1

while H > 1:
    H = math.floor(H/2)
    count += 2**i
    i += 1
print(count)

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

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

count = 1
ans = 0

while h != 0:
    ans += count
    h = h//2
    count *=2

print(ans)

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

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

N=100
p=[1]*(N+1)
for i in range(N):
    p[i+1]=p[i]*2
    
index=0
for i in range(N):
    if H==p[1]:
        index=i
    if H<p[i]:
        index=i-1
        break
        
print(p[index+1]-1)

Solution (Python):
from math import log, floor
H = int(input())
f = floor(log(H, 2))

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

Solution (Python):
from functools import lru_cache

@lru_cache(None)
def rec(n):
    if n == 1:return 1
    if n == 0:return 0
    
    return 1 + 2*rec(n//2)
    
    

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

Solution (Python):
def cara(n):
    if n < 2:
        return 1
    else:
        return (1 + (2 * cara(n // 2)))


h = int(input())

print(cara(h))

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

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

Solution (Python):
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    h = get_int()
    print((1<<h.bit_length()) - 1)




''' Pythonista fLite 1.1 '''
import sys





out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()

print(*out, sep='\n')

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

while H != 1:
  H = H//2
  k += 1

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

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

Solution (Python):
h=int(input())
ans=0
count=1
while(True):
  if h==1:break
  count+=1
  h=h//2
for i in range(count):
  ans+=2**i
print(ans)

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

cnt = 0
index = 0

while H > 0:
    H //= 2
    cnt += 2**index
    index += 1

print(cnt)

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

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

print(2 ** cnt - 1)

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

print(ans)

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def memodict(f):
    """ Memoization decorator for a function taking a single argument. """
    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__


@memodict
def solve(x):
    if x == 1:
        return 1
    return 2 * solve(x // 2) + 1


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




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
import math
h = int(input())
count = 0
ans = 0
while h > 0:
    if h == 1:
        h = 0
    else:
        h = math.ceil(h // 2)
    ans += 2 ** count
    count += 1
print(ans)

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


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

Solution (Python):
from functools import lru_cache
import sys
sys.setrecursionlimit(10000000)
@lru_cache(maxsize= 10 ** 7)
def solve(n):
  if n == 1:
    return 1
  else:
    return solve(n//2) * 2 + 1
h = int(input())
print(solve(h))

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

sou = int(math.log2(h))


ans = 1 + (2**(sou)-2)/(2-1) + 2**(sou)

print(int(ans))

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

def main():
    H = INT()
    count = 0
    
    while H != 1:
        H = H // 2
        count += 1
    print(2 ** (count) * 2 - 1)
    
    
    
    
    




if __name__ == "__main__":
    main()

Solution (Python):






from sys import stdin,setrecursionlimit










setrecursionlimit(10**6)
input=stdin.readline

h=int(input().rstrip())
cnt,ans=1,0
while h>1:
    h//=2
    ans+=cnt
    cnt*=2
    
print(ans+cnt)

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

n = 1
result = 0
while h:
    result += n
    if h == 1:
        break
    h //= 2
    n *= 2

print(result)

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

print(c-1)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
H = int(input())
L = len(bin(H)) - 2
print(2**L - 1)

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

num = int(log2(h))
ans = 0
for i in range(1, num+1):
    ans += 2 ** i
print(1+ans)

Solution (Python):
x = int(input())
bin_str = format(x, 'b')
ketasuu = len(bin_str)
print(2 ** ketasuu - 1)

Solution (Python):
H = int(input())
n = 1
h = H
while True:
    if h == 1:
        break
    n *= 2
    h = h//2

print(n*2-1)

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

count = 0

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

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

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

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

ans = 1
add = 2
while ans < h:
    ans += add
    add *= 2
    
print(ans)

Solution (Python):



def solve(*args: str) -> str:
    h = int(args[0])
    return str((1 << len(format(h, 'b'))) - 1)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

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

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

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

twos = [2 ** i for i in range(41)]

for val in twos:
    if H < val:
        print(val-1)
        break

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

Solution (Python):
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    
    

    
    
    
    
    

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

if __name__ == '__main__':
    main()

Solution (Python):
from math import log

H = int(input())

print(sum(
    2 ** i
    for i in range(int(log(H, 2)) + 1)
))

Solution (Python):
import sys

stdin = sys.stdin

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

h = ni()
c = 1
ans = 0
while h:
    ans += c
    c <<= 1
    h >>= 1
print(ans)

Solution (Python):


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

Solution (Python):
h = int(input())
def pow(n, p): 
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2
            p //= 2
        else:
            res = res * n
            p -= 1
    return res

for i in range(1,10*100):
    if h < pow(2,i):
        p = i-1
        break
ans = 0
for i in range(p+1):
    ans += 2**i
print(ans)

Solution (Python):
import sys
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()))

h=INT()
cnt=0
while h>1:
    
    cnt+=1
    h//=2


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

Solution (Python):

H=int(input())
memo=[0]*(10**7)
memo[1],memo[2]=1,3
def atk(N):
    if N>10**6:
        return 2*atk(N//2)+1
    else:
        if memo[N]==0:
            memo[N]=2*atk(N//2)+1
        return memo[N]
    
print(atk(H))

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

Solution (Python):
H = int(input())
bin_num = format(H, 'b')
ans = 2**(len(bin_num))-1
print(ans)

Solution (Python):
import math
import sys
sys.setrecursionlimit(10 ** 6)


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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
H=int(input())

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

print(sai(H))

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

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