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

i = 1
sm = 1

if H == 1:
    print(1)
    exit()
else:
    while 1:
        H = H // 2
    
        sm += 2**i
        i += 1
    
        if H == 1:
            break

print(sm)

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

H = INT()

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

cnt = 1

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

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

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

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

t=pow(2,cnt) -1
print(t+2**cnt)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    M=int(input())
    
    log = 0
    while M >= 2:
        M = M // 2
        log += 1
    ans=0
    for i in range(log+1):
        ans+=2**i
    print(ans)


resolve()

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

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

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

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

Solution (Python):
H = int(input())
def divdivdiv(num):
  cc = 0
  while num:
    num //= 2
    cc += 1
  return cc

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

Solution (Python):
H = int(input())
cnt = 0
num = 0
while True:
  cnt += 1
  num += pow(2,cnt-1)
  H=H//2
  if H==0:break
print(num)

Solution (Python):
from math import floor

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

H = int(input())

ans = attack(H)
print(ans)

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

Solution (Python):

"""
Created on Sun Apr 12 17:15:55 2020

@author: Kanaru Sato
"""

h = int(input())
count = 0

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

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

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

Solution (Python):
from math import floor
def kill(life):
    if life in dp.keys():
        return dp[life]
    if life == 1:
        dp[life] = 1
        return 1
    elif life > 1:
        dp[life] = kill(floor(life/2)) * 2 + 1
        return dp[life]
h = int(input())
dp = {}
print(kill(h))

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

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

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

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

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

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

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

Solution (Python):
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""
import math
n=int(input())
ans=int(pow(2,int(math.log2(n)+1))-1)
print(ans)

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

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

h = n_in()
import math

def do(x):
    if x == 1:
        return 1
    return 1+2*do(math.floor(x/2))

print(do(h))

Solution (Python):
import sys

H = int(input())

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

n = 1
ans = 1
dH = H
while True:
    dH = dH // 2
    ans += 2**n
    n += 1
    if dH <= 1:
        break

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h = int(readline())
cnt = 0
if h == 1:
    print(1)
elif h == 2:
    print(3)
else:
    for i in range(h):
        if h < 2 ** i:
            print(cnt)
            exit()
        else:
            cnt += 2 ** i

Solution (Python):

import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

H = ir()
answer = attack(H)
print(answer)

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

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

while H:
    H = H >> 1
    ans += now
    now = now << 1

print(ans)

Solution (Python):
H = int(input())
i = 0
while True:
    if H >= int(pow(2,i)):
        i += 1
    else:
        break
print(int(pow(2,i)-1))

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

Solution (Python):
def atk(H):
    if H == 1:
        return(H)
    else:
        global count
        count += 1
        return(atk(H//2))
count = 0
atk(int(input()))
print(-1*(1-(2**(count+1))))

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

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

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

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

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

i = 1
while 1:
    if h<2**i:
        print(2**i-1)
        exit()
    else:
        i+=1

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

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

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

Solution (Python):
h = int(input())
h_s = bin(h)[2:]
h_s_len = len(h_s)

count_dict = {1: 1}
for i in range(2, h_s_len + 1):
    x = int(h_s[:i], 2)
    count_dict[x] = 1 + 2 * count_dict[x >> 1]

ans = count_dict[h]
print(ans)

Solution (Python):
def check_count_func():
    count_dict = {}

    def check_count(x):
        if x in count_dict:
            return count_dict[x]
        
        if x == 1:
            return 1
        
        count_dict[x] = 1 + 2 * check_count(x >> 1)
        return count_dict[x]
    
    return check_count


h = int(input())
h_s = bin(h)[2:]
h_s_len = len(h_s)

f = check_count_func()
for i in range(1, h_s_len):
    x = int(h_s[:i], 2)
    f(x)

ans = f(h)
print(ans)

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

p = math.floor(math.log2(H))
print(2 ** (p + 1) - 1)

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

h=n0()

c=1
s=0
while h>0:
    if h>1:
        h=int(h/2)
        s=s+c
        c=c*2
    else:
        h=0
        s=s+c
print(s)

Solution (Python):
def attack(num, cnt):
    cnt+=1
    if num==1:
        return cnt
    else:
        return attack(num//2, cnt)

    
H = int(input())
cnt=0
cnt = attack(H, cnt)
tmp = [2**x for x in range(cnt)]
print(sum(tmp))

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

while h >= 1:
    h //= 2
    attack_counter *= 2

print(attack_counter + h - 1)

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

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

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

from collections import deque

d = deque([H])

count = 0
sm = 0
while 1:
    if H == 1:
        break

    H //= 2
    count += 1
    sm += 2**count

print(sm+1)

Solution (Python):
import math
H = int(input())
n = math.floor(math.log(H, 2))
c = 1
for i in range(n):
    c += (2 ** (i+1))
print(c)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
H = int(input())
D = {1: 1}


def dfs(H):
    if H in D:
        return D[H]

    D[H] = dfs(H//2) + dfs(H//2) + 1
    return D[H]


print(dfs(H))

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

counter = 0

while n > 0:
  n = n//2
  counter += 1
  
counter = 2**counter-1

print(counter)

Solution (Python):

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

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

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

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

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

ans = 0
cnt = 0

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

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

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

Solution (Python):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect




from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  h = int(readline())
  def attack(x):
    if x==1:
      return 1
    else:
      x = x//2
      return 1+2*attack(x)
  print(attack(h))
  
  
if __name__ == '__main__':
  main()

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

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

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

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

count = 0
while True:
    count += 1
    if h == 1:
        break
    else:
        h = math.floor(h/2)

print(pow(2, count)-1)

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

Solution (Python):
mod = 10**9 + 7

def main():
    H = iip(listed=False)
    N = 1

    ret = 0
    while True:
        ret += N
        if H == 1:
            break
        else:
            H //= 2
            N *= 2
    print(ret)




def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        return r
    if side == "right":
        return l+1



def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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


if __name__ == '__main__':
    main()

Solution (Python):
H=int(input())
def count(H):
  s=1
  c=1
  while H!=1:
    H=H//2
    c*=2
    s+=c
  return s
print(count(H))

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

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

print(ans)

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

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

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

resolve()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

if count == 0:
    print(1)
else:
    print(2**(count+1)-1)

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

Solution (Python):
import numpy as np
n =int(input())
ans = 1
for i in range(int(np.log2(n))):
    ans += 2**(i+1)
    
print(ans)

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

ans=0
p=0
for i in range(41):
    n=2**i
    if h<n:
        p=2**(i-1)
        break

print(2*p-1)

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

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

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

print(dev_(h))

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

h=int(input())

print(attack(h))

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

Solution (Python):

import sys


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



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


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
a=0
d=1
while d<=N:
  a+=d
  d*=2
print(a)

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

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

Solution (Python):
global counter
counter=0
def slove(H):
    if H==1:
        return 1
    else:
        return 2*slove(H//2)+1
H=int(input())
print(slove(H))

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

Solution (Python):
import sys
from functools import lru_cache
@lru_cache(maxsize=None)
def alg_memoization_recursion(n):
    if n==1:
        return 1
    else:
        return alg_memoization_recursion(n//2) + alg_memoization_recursion(n//2) + 1

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

if __name__ == '__main__':
    solve()

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

Solution (Python):





import math

h = int(input())
double_by_attack = int(1)
trial_of_attack = int(0)


for i in range(h):
    if h > 1:
        trial_of_attack = trial_of_attack + double_by_attack
        double_by_attack = double_by_attack * 2
        h = math.floor(h/2)
    else:
        trial_of_attack = trial_of_attack + double_by_attack
        print(trial_of_attack)
        break

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

a = int(math.log(H,2))

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

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

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

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

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

while H > 1:
    ans += monsterno
    H //= 2
    monsterno *= 2

print(ans+monsterno)

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

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

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

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

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

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

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

n = 0
H_bin = bin(H)
length = len(H_bin) - 2

ans_bin = "0b"
for _ in range(length):
    ans_bin += "1"

print(int(ans_bin, 2))

Solution (Python):
H = int(input())
ans = 0
num = 1
A = [1]
for i in range(100):
  if H / 2 < 1:
    ans += 1
    break
  else:
    H = H / 2
    ans += 1
for j in range(ans-1):
  A.append(num*2)
  num = num*2
print(sum(A))

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

    print(ans)

main()

Solution (Python):
h = int(input())
ans = 0
i = 0
while h > 0:
    if h == 1:
        h = 0
        ans += pow(2, i)
        i += 1
    else:
        h = h // 2
        ans += pow(2, i)
        i += 1
print(ans)

Solution (Python):
h = int(input())
dep = 0
def log_num(n):
    global dep
    if n == 1:
        return dep
    else:
        dep += 1
        log_num(n//2)
log_num(h)
ans = 1
for i in range(dep+1):
    ans *= 2
print(ans-1)

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

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

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

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

Solution (Python):
import math

H = int(input())
N = math.floor(math.log(H,2))

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

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

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

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

Solution (Python):
import sys

x = sys.stdin.readline()
h = int(x)

def dp(h):
  if(h != 1):
    return( dp(int(h/2)) * 2 + 1)
  else:
    return 1

count = dp(h)
print(count)

sys.stdout.flush()

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

q = N
cnt = 0

while (q > 1) :
    q = q // 2
    cnt += 1

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

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

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

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

print (ans)

Solution (Python):

H = int(input())


kougeki_kaisu = [1]
monster_num =1

while 1 < H:
    H = H // 2
    monster_num = monster_num * 2
    kougeki_kaisu.append(monster_num)
    

print(sum(kougeki_kaisu))

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

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

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

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

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

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

hp = int(input())
print(attack(hp))

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

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

print(dfs(N))

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

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

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

import math

print((2**(math.floor(math.log2(x))+1))-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):
H = int(input())
i = 0
ret = 1
while H != 1:
    i += 1
    ret += 2 ** i
    H = H // 2
print(ret)

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

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

print(f(H))

Solution (Python):
import math

h = int(input())

count = 0
while True:
    if h == 1:
        break
    h = int(h / 2)
    count += 1
print(pow(2, count + 1) - 1)
exit(0)


l = math.log(h + 1, 2)
print(pow(2, math.ceil(l)) - 1)

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

ans = 0
cnt = 1
for i in range(100):
    if h == 1:
        break
    else:
        h = int(h / 2)
        cnt *= 2
    ans += cnt
print(ans + 1)

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

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

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

print(att(n))

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

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

Solution (Python):
import copy
import math
import string

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

while H > 0:
    ans += cnt
    H //= 2
    cnt *= 2

print(ans)

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:23/03/2020
'''


from math import ceil
def main():
    
    
    
    
    
    
    
    
    
    
    
    ans=0
    n=int(input())
    if(n==1):
        print('1')
    elif(n==2 or n==3):
        print('3')
    else:
        ans=0
        c=1
        while(n>3):
            ans+=c
            c*=2
            n//=2
        ans+=(3*c)
        print(ans)
    
    
    
    
    
    
    
    
    
if __name__ =="__main__":
    main()

Solution (Python):

h = int(input())

def calc_ans(h, n):
    if h == 1:
        return 2 ** n
    else:
        return 2 ** n + calc_ans(h // 2, n + 1)
print(calc_ans(h, 0))

Solution (Python):
n=int(input())
hoge=bin(n)
hoge=hoge[::-1]
ans=0
atk=0
for i in range(len(hoge)-2):
  atk=1+atk*2
  ans=atk*int(hoge[i])
  
print(ans)

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

a=0
i=0
while a<h:
    a+=2**i
    i+=1
print(a)

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

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

Solution (Python):
h = int(input())
if(h == 1):
  print(1)
  exit()
cnt = 1
point = 0
list = [0 for i in range(100)]
while (h>point+1):
  list[cnt] = ((list[cnt-1] * 2) +1)
  point += 2**cnt
  cnt += 1

print(list[cnt-1]*2+1)

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

while True:
    if H < 2**i:
        print(2**i-1)
        sys.exit()
    i += 1

Solution (Python):
import sys
H=int(input())
numlist = []
i = 1
if H == 1:
    print('1')
    sys.exit()

while True:
    if H < 2**i:
        print(2**i-1)
        sys.exit()
    i += 1

Solution (Python):
import sys
H=int(input())
numlist = []
i = 1
if H == 1:
    print('1')
    sys.exit()

while True:
    tmp = 2**i
    numlist.append(tmp)
    i += 1
    if tmp >= 1000000000000:
        break

for i in range(1,len(numlist)):
    if H < numlist[i]:
        print(numlist[i-1]*2-1)
        sys.exit()

Solution (Python):
import sys
sys.setrecursionlimit(10000) 
from functools import lru_cache
@lru_cache(maxsize=1000) 

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

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



if __name__ == "__main__":
    main()

Solution (Python):
def gausu(x):
    if x%2==0:
        return int(x/2)
    if x%2==1:
        return int((x-1)/2)
h=int(input())
i=0
while h!=1:
    h=gausu(h)
    i=i+1

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

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

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

cnt = 0
num_monster = 1

while True:
    if h == 1:
        cnt += num_monster
        break
    else:
        cnt += num_monster
        num_monster *= 2
        h = int(h / 2)

print(cnt)

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

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

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

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

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

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

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

Solution (Python):
import math

h = int(input())




print((1-2**math.floor(math.log(h,2)))//(1-2)+2**math.floor(math.log(h,2)))

Solution (Python):
import math

h = int(input())

print((1-2**math.floor(math.log(h,2)))//(1-2)+2**math.floor(math.log(h,2)))

Solution (Python):
import math

h = int(input())

print((1-2**math.floor(math.log(h,2)))//(1-2)+2**math.floor(math.log(h,2)))

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

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

print(f(n))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)

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

h = int(input())

ans = attack(h)

print(ans)

Solution (Python):

h = int(input())

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

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

print(attack(h))

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

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())
ans = 0
ms = [(H, 1)]
while ms:
  m, c = ms.pop()
  ans += c
  if m > 1:
    ms.append((m // 2, c * 2))
print(ans)

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

Solution (Python):
from math import log2
H = int(input())
c = int(log2(H))
ans = (1 << (c + 1)) - 1
print(ans)

Solution (Python):
H = int(input())
 
 
def main(H):
  if H == 1:
    return 1
  else:
    return main(H//2)*2 + 1
 
if __name__=='__main__':
  print(main(H))

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

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

Solution (Python):
import math

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

Solution (Python):
from functools import lru_cache

@lru_cache(maxsize=None)
def attack(x):
    if x == 1:
        return 1
    nxt = x // 2
    return 1 + 2 * attack(nxt)


def submit():
    h = int(input())
    print(attack(h))


if __name__ == "__main__":
    submit()

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

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

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

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

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

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

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

count = 0
m = 1
while h:
    if h == 1:
        count += m
        h = 0
    else:
        h = h//2
        count += m
        m *= 2

print(count)

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

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

    print(2**tmp-1)
    
 
if __name__ == '__main__':
    main()

Solution (Python):
import math

H = int(input())
if H == 1:
    print(1)
else:
    height = int(math.log2(H))
    print(2 * (2 ** height) - 1)

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

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

print(ans(h))

Solution (Python):
import sys

H=int(input())
M=[]

for i in range(41):
   M.append(2**i)

for i in range(41):
    if H<M[i]:
        print(M[i]-1)
        sys.exit()