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):
x = int(input())
y = x
d = {}
d[x] = 0
while x > 0:
    x = x // 2
    d[x] = 0
d[1] = 1
for k in sorted(d.keys()):
    if k == 0:
        d[k] = 0
    else:
        d[k] = 1 + 2 * d[k // 2]
print(d[y])

Solution (Python):
import math

def fun(x):
	if x==1:
		return 1
	return (2*fun(math.floor(x/2)))+1
n=int(input())
print(fun(n))

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

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

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

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

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

def calc(hp):
    if hp <= 1:
        return 1
    return calc(hp // 2) * 2 + 1

print(calc(h))

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

Solution (Python):
h=int(input())
ans=1
while ans<h:
    ans=ans<<1|1
print(ans)

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

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

if __name__ == "__main__":
    H = int(input())
    ans = solve(H)
    print(ans)

Solution (Python):
H = int(input())
h = H
d = [0]
while h > 0:
    d.append(h)
    h = h//2
d.sort()
attack = {}
attack[0] = 0
for i in range(1,len(d)):
    attack[d[i]] = 2*attack[d[i-1]] + 1
print(attack[H])

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

def hit_point(N):
    if N == 1:
        return 1
    else:
        return 2 * hit_point(N//2) + 1
        
print(hit_point(H))

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


def s(a):
    if a == 0:
        return 0
    return 2*s(a//2)+1


print(s(n))

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


def s(a):
    if a == 0:
        return 0
    return 2*s(a//2)+1


print(s(n))

Solution (Python):
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H = I()
    def dfs(x):
        if x == 1:
            return 1
        return 2 * dfs(x//2) + 1
    print(dfs(H))
if __name__ == '__main__':
    main()

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

print(2**n-1)

Solution (Python):

h = int(input())
ans = 0
attack = 1
while (1):
    h //= 2
    ans += attack
    if h == 0:
        break
    else:
        attack *= 2

print(ans)

Solution (Python):
hp = int(input())
attack = 0
monster = 1
p = 1

for i in range(999):
    if hp == 0:
        break
    else:
        attack += 1
        hp = hp // 2

print(2 ** attack - 1)

Solution (Python):
hp = int(input())
if hp == 0:
    print(1)
    exit()

attack = 0
monster = 1
p = 1

for i in range(999):
    if hp == 0:
        break
    else:
        attack += 1
        hp = hp // 2

print(2 ** attack - 1)

Solution (Python):
from math import log2


def solve(string):
    return str(2**(1 + int(log2(int(string)))) - 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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


if __name__ == '__main__':
    main()

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):


def f(h):
    cnt = 0
    while h > 0:
        h = h//2 
        cnt += 1
    return cnt

def main():
    h = int(input())
    print(pow(2, f(h)) -1)

main()

Solution (Python):


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

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

main()

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

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

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

Solution (Python):
import math

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

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

Solution (Python):
d = {1: 1}

def f(x): 
    if x in d.keys(): return d[x]
    d[x] = 2 * f((x)//2) + 1

    return d[x]

print(f(int(input())))

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

def count1(h):
    if(h==0):
        return 0
    if(h==1):
        return 1
    return 1 + 2*count1(h//2)
    
print(count1(h))

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

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

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

count = 0

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

ans = pow(2, count) - 1

print(ans)

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

ans = 0
m = 1

while h > 0:
    ans += m
    h //= 2
    m *= 2

print(ans)

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

count = 0

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

print(pow(2, count) - 1)

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

count = 0

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

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

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

list = []

for i in range(50):
  count = pow(2, i)
  if count > h:
    break
  list.append(count)
    
print(sum(list))

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

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

count = 1

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

print(count)

Solution (Python):
def search_H(H):
    if H==1:
        return 1
    return 2*search_H(H//2) + 1
H_1 = int(input())
print(search_H(H_1))

Solution (Python):
import math

input_num=input()
N=int(input_num)


t=1+int(math.log2(N))

def f(n):
  NUM=0
  if n==1:
    NUM=1
  else:
    NUM=f(n-1)*2+1
  return NUM

print(f(t))

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

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

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

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

ans=BCount(H)

print(ans)

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

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

ans=BCount(H)

print(ans)

Solution (Python):
H = int(input())
n = 1
c = 0

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

print(n + c)

Solution (Python):
def quick_mod(a,b):
    res=1
    while b!=0 :
        if b&1 :
            res*=a
        a*=a
        b>>=1
    return res

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

Solution (Python):
import math
H=float(raw_input())
con = 0
while True:
  H = math.ceil(int(H/2))
  con += 1
  if H == 0:
    break
print 2 ** con - 1

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

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

print(i)

Solution (Python):

H = int(input())


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

answer = 2**(answer+1) - 1

print(answer)

Solution (Python):




"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

import math
def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = int(input())
    a = 0  
    b = 0  
    while s > 0:
        s = float(s / 2)
        a += pow(2, b)
        b += 1
        if s < 1:
            break
    print(a)
    return 0

if __name__ == '__main__':
    
    

    
    
    import doctest
    doctest.testmod()

    
    import sys
    sys.exit(main())

Solution (Python):
import numpy as np
listW = [int(2 ** i) for i in range(40)]
listAns = np.array(listW).cumsum()

H = int(input())
for val in listAns:
    if H <= val:
        print(val)
        exit()

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

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

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

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

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

Solution (Python):
from collections import defaultdict

H = int(input())
cnt = defaultdict(int)
cnt[1] = 1

def dfs(n):
  if cnt[n] == 0:
    cnt[n] = 2 * dfs(n // 2) + 1
  return cnt[n]

print(dfs(H))

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

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

print(func(h))

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

Sum = 0

for i in range(10**12):
    Sum += 2**i
    if H > 1:
        H = H // 2
    else:
        break
        
print(Sum)

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

res = 0
monster = 1
while h > 0:
    res += monster
    h //= 2
    monster *= 2

print(res)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
H = int(input())

def battle(h, cnt):
    if h == 1:
        return cnt
    return battle(h//2, cnt * 2 + 1)

print(battle(H, 1))

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

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

Solution (Python):
def monster(H):
  if H>1:
    return 2*monster(int(H//2))+1
  else:
    return 1

H = int(input())

print(monster(H))

Solution (Python):
from math import log2 as ln

h = int(input())
c = int(ln(h))
s = 0
for i in range(c+1):
  s += 2**i
print(s)

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

while H !=1:
 
  H = H//2
  c+=1
  
print(2**(c+1)-1)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h = inp()
cnt = 0
tmp = h
while True:
    if tmp <= 1:
        break
    tmp //= 2
    cnt += 1
print(2**(cnt+1)-1)

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

b = format(h, "0b")

index = 0
ans = 0
for _b in b:
    ans += 2**index
    index += 1

print(ans)

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

def aaa(i):
    if i == 1:
        return(1)
    else:
        return 2*aaa(i//2)+1
print(aaa(h))

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


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

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(raw_input())
def f(x):
 if x==1:
  return 1
 return 1+f(x/2)*2
print f(h)

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

print(c)

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

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

print(f(h))

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

cnt = 1
res = 0

while h > 0:
    h = h // 2
    res += cnt
    cnt *= 2

print(res)

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

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


H = int(input())
print(rec(H))

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

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

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

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

def souwa(N):
    num = 0
    for i in range(N):
        num = num + 2**i
    return num

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

print(2**count+souwa(count))

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


def calc(n, depth=0):
    if n == 1:
        return depth + 1
    else:
        return calc(n // 2, depth + 1)


print(2 ** calc(H) - 1)

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

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

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

kai = 0
k_sum = 0
while True:
  if k_sum >= N:
    break
  k_sum += 2 ** kai
  kai += 1
  
print(k_sum)

Solution (Python):
import sys
import math
sys.setrecursionlimit(10 ** 9)
 
def func(h,ans):  
  if h == 1:
    return ans+1
  if h > 1:
    return 2 * func(math.floor(h/2),ans) + 1
  
h = int(input())
ans = 0
print(func(h,ans))

Solution (Python):






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

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

Solution (Python):
import math
from functools import lru_cache

H = int(input())

@lru_cache()
def atack(monster):
  if monster == 1:
    return 1
  else:
    spawn = math.floor(monster / 2)
    return atack(spawn) + atack(spawn) + 1
  
print(atack(H))

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

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

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

Solution (Python):

def main():
    H = int(input())
    print((1 << H.bit_length()) - 1)


if __name__ == "__main__":
    main()

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


n = int(math.log(H, 2))
ans = 0

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

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

Solution (Python):

def main():
    H = int(input())
    cnt, p = 0, 0
    while H:
        H >>= 1
        cnt += 1 << p
        p += 1
    print(cnt)


if __name__ == "__main__":
    main()

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

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

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

ans = 1
if H > 1:
    prev, curr = 1, 2
    while 2**curr <= H:
        prev = curr
        curr = curr + 1

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

print(ans)

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

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

H = int(input())
print(red(H))

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


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

print(f(h))

Solution (Python):
counter=0
count=0
x=int(input())
while x:
  x=x//2
  counter=counter+2**count
  count+=1
print(counter)

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

while h != 1:
    h=h//2
    kaisuu += 1
    
print(str(2**(kaisuu+1)-1))

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

Solution (Python):
from sys import stdin

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

h = int(stdin.readline())
print(f(h))

Solution (Python):
H = int(input())
k = 1
for i in range(1000000):
    if H != 1:
        H = H//2
        k = k + 1
    else:
        break
print(2**k - 1)

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

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

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

print(f(H))

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

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

print(2**cnt - 1)

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

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

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

Solution (Python):
def saiki(N):
  if N==1:
    return 1
  a=saiki(N//2)*2+1
  return a
N =int(input())
print(saiki(N))

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

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

Solution (Python):
import sys

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

    solve(H)

def solve(H: int):
    count = 0
    while 0 < H:
        H = H // 2
        count = count + 1

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

    print(answer)

    return
 
if __name__ == "__main__":
    propare()

Solution (Python):
f = lambda x: 2*f(x//2)+1 if x>1 else 1
print(f(int(input())))

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

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

print(f(int(input())))

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



h = int(input().strip())
k = math.floor(math.log(h, 2))
print(2 ** (k + 1) - 1)

Solution (Python):
def main():
    H = int(input())
    ans = 0
    x = 1
    while H > 0:
        ans += x
        H = H >> 1
        x = x << 1
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):




import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)


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


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

    res = f(H)

    print(res)



main()

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

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

Solution (Python):

from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)

def pin(type=int):
    return map(type,input().split())

H,=pin()

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

print(crcl(H))

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

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

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

print(2**count -1)

Solution (Python):


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

Solution (Python):
h=int(input())
x=h
ans,cnt=0,0
while x>0:
    cnt+=1
    x//=2
for i in range(cnt):
    ans+=pow(2,i)

print(ans)

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

def rec(a):
    if a==1:
        return 1
    else:
        return rec(a//2)*2+1
    
print(rec(H))

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

ret = 0
mon = 1
while H:
    H >>= 1
    ret += mon
    mon <<= 1
print(ret)

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


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


print(a(int(input())))

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

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

h = int(input())
print(solve(h))

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

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

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

con = 0
t = 0

while H > 0:
  H = H // 2
  con += 2 ** (t)
  t += 1
  
print(con)

Solution (Python):
from math import log

h=int(input())
a=int(log(h,2))
print(pow(2,a+1)-1)

Solution (Python):
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)


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


print(a(int(input())))

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

ans+=n
print(ans)

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

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

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

print(ans)

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

while (ans <= n):
    ans *= 2
print(ans-1)

Solution (Python):
import math


H = int(input())

def attacks(health):
    if health == 1:
        return 1
    
    return 1 + 2 * attacks(health//2)

print(attacks(H))

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

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

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

ret = 0
mon = 1
while H:
    H //= 2
    ret += mon
    mon <<= 1
print(ret)

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

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

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):
print(2**int(input()).bit_length()-1)

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

Solution (Python):
import math 
 
h=int(input())
x =math.floor(math.log(h,2))
print( sum([2**y for y in range(x+1)]))

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

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

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

print(count)

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

Solution (Python):
def main():
    H = int(input())
    ans = 0
    from math import log2
    for h in range(int(log2(H)) + 1):
        ans += 2**h
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
class Main:
    import math
    H = int(input())
    num = 0
    if H == 1:
        num = 1
    else:
        cnt = int(math.log(H, 2))
        for i in range(cnt+1):
            num += 2 ** i
    print(num)

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

if H == 1:
    ans == 'NA'
else:
    for i in range(100000000000):
        cnt = cnt//2
        B.append(cnt)
        if cnt == 1:
            break

C =[1]
for i in range(1,1001):
    C.append(C[i-1]*2)

if ans == 'NA':
    print('0')
else:
    for i in range(len(B)):
        ans +=C[i]
print(ans)

Solution (Python):
h = int(input())
mem = [0] * 100
cnt = 0
 
def atk(k):
    if k == 1:
        mem[1] = 1
        return 1
    else:
        j = int(k // 2)
        l = 0
        while k / ( 2 ** l) >1:
            l += 1
 
        if mem[l] == 0:
            mem[l] = atk(j) * 2 + 1
            return mem[l]
        else:        
            return mem[l]

atk(h)
mem.sort(reverse = True)
print(mem[0])

Solution (Python):


h = int(input())
count = 0
enemy = 1
while True:
    if h == 1:
        count += enemy
        break
    else:
        count += enemy
        h = int(h / 2)
        enemy *= 2
print(count)

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

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

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

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

i = 0
while H / 2 != 0:
  H = H // 2
  i += 1

result = 2 ** i - 1

print(result)

Solution (Python):

def main():
    import math

    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H, 2))
        ans = 0
        for i in range(count+1):
            ans += 2 ** (i)
        print(ans)

if __name__ == "__main__":
    main()

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

n = h.bit_length()

print(2 ** n - 1)

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

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Solution (Python):

"""
Created on Sun Jan 26 21:17:50 2020

@author: H_Hoshigi
"""

H = int(input())

total_attack = 0

now_H = H
now_N = 1
while now_H > 1:
    total_attack += now_N
    now_H = now_H // 2
    now_N = now_N * 2
total_attack += now_N

print(total_attack)

Solution (Python):
def main():
    import math
    H = int(input())
    ans = 0
    for i in range(int(math.log(H,2))+1):
        ans += 2**(i)
    print(ans)

if __name__ == '__main__':
    main()

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

def solve(x):
    if x==1:
        return 1
    if x ==0:
        return 0
    
    return 2*solve(x//2)+1
    
print(solve(h))

Solution (Python):
def main():
    import math
    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H,2))
        ans = 0
        for i in range(count+1):
            ans += 2**(i)
        print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
import math

h = int(input())

def sum(list,k):
    s = 0
    for i in range(len(list)-k):
        s = s+ list[i]
    return s

x = math.ceil(math.log2((h+1)*1.0))


print(2**x - 1)

Solution (Python):
import sys
H = int(input())
cnt,n = 0,1
while(H!=0):
    H = int(H/2)
    cnt += n
    n = n * 2
print(cnt)
def input():
    return sys.stdin.readline()[:-1]

Solution (Python):
h_ = int(input())
h = h_
ans = 0
count = 1
for i in range(h):
  if h <= 1:
    break
  count += 1
  h = h//2

print((2 ** count)-1)

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

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

Solution (Python):
import math

h = int(input())

x = int(math.log2(h))
res = 2**(x+1)-1

print(res)

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

Solution (Python):
def d_caracal_vs_monster():
    return 2**int(input()).bit_length() - 1

print(d_caracal_vs_monster())

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

print(answer)

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

Solution (Python):

import math
i = int(input())
low = 0
high = 45
for _ in range(100):
    l = 2**low
    h = 2**high
    m = 2**((low+high)/2)
    if i < m:
        high = (low+high)/2
    else:
        low = (low+high)/2

tmp = math.floor(high) + 1
print((2**tmp)-1)

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


h = int(input())
print(findans(h))

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


ans = 0
k = 1
while True:
  n //=2
  ans += k
  k *= 2
  if n == 1:
    print(ans+k)
    break
  elif n < 1:
    print(ans)
    break

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

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

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

print(d_caracal_vs_monster())

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

cnt = 0
result = 0


def gener():
  now = 3
  while True:
    yield now
    now = now*2+1


if H == 1:
  print(1)
elif H == 2 or H == 3:
  print(3)
else:
  while True:
    if H <= 1:
      break
    cnt += 1
    H = int(H / 2)

  
  gen = gener()
  gen.__next__()

  for i in range(int(cnt)):
    if i == cnt-2:
      result = gen.__next__()
      print(result)
    else:
      gen.__next__()

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









ans = math.log2(h)
ans = int(ans)


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

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

else:
  print(H)

Solution (Python):
H=int(input())
I=0
J=[1]

if H==1:
    print(1)

else:
    for i in range(1,10**4):
        I=int(H/(2**i))
        J.append(2**i)

        if I==1:
            print(sum(J))

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

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