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 fractions import gcd


import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7



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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors


def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret


class UnionFind:
    def __init__(self, n):
        self.sz = [-1 for i in range(n)]

    
    def find(self, x):
        if self.sz[x] < 0:
            return x
        else:
            self.sz[x] = self.find(self.sz[x])
            return self.sz[x]

    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.sz[x] > self.sz[y]:
            x, y = y, x
        self.sz[x] += self.sz[y]
        self.sz[y] = x

    
    def same(self, x, y):
        return self.find(x) == self.find(y)

    
    def size(self, x):
        return -self.sz[self.find(x)]


def main():
    h = int(input())
    t = h
    k = 0
    while t > 1:
        t //= 2
        k += 1
    k+=1
    print(2**k - 1)




            


    




    


if __name__ == '__main__':
    main()

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

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

if H == 1:
  print(1)

else:
  sp = 0
  count = 1
  while H != 1:
    H = H // 2
    count *= 2
    sp += count
  print(count*2-1)

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

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

print(count)

Solution (Python):
H=int(input())
import math
j=(math.log2(H))//1

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

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

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

while h > 0:
    h = math.floor(h / 2)
    ans *= 2

print(ans-1)

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

def time(h):
    if h == 1:
        return 1
    elif h > 1:
        return time(h//2)*2 + 1

print(time(H))

Solution (Python):
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
h = i()
n = 0
while h > 0:
    h = h//2
    n += 1
print(2**n-1)

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

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

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

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

r = func(H)
print(r)

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

Solution (Python):
import numpy as np

H = int(input())

num_cut = 0
ans = 0
while(H > 0):
    H = int(H/2)
    ans += 2**(num_cut)
    num_cut += 1

print(ans)

Solution (Python):


import sys
import math

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

def main():
    h = int(sys.stdin.readline())
    print(f(h))

if __name__ == '__main__':
    main()

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

def ref(H,d):
  d = d+1
  if 1 < H:
  	H, d = ref(H//2,d*2)
  return H, d

_, d = ref(H,0)

print(d)

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

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

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

print(rec(h) - 1)

Solution (Python):
import math

monster_health = int(input())

hits = 0
last_hit = 1

while monster_health >= 1:
    monster_health = math.floor(monster_health / 2)
    hits += last_hit
    last_hit *= 2

print(hits)

Solution (Python):
N=int(input())
C=0
while N!=0:
    N=N//2
    C=C+1
A=[2**i for i in range(C)]
print(sum(A))

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

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

for i in range(h+1):
    if 2**i <= h:
        c += 2**i
    else:
        break

print(c)

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

count=0
for _ in range(48): 
  if H==1:
    print(2**(count+1)-1)
    exit()
  H=H//2
  count+=1

Solution (Python):
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) 
A = [int(input()) for _ in range(N)] 
lst = [list(map(int,input().split())) for i in range(M)] 
"""

H = int(input())
n_bin = len(bin(H)[2:])

ans = 2 ** n_bin - 1

print(ans)

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

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

Solution (Python):
import numpy as np
H = int(input())
N = int(np.log2(H))
C = pow(2, N+1)-1
print(C)

Solution (Python):

import sys
import math
h = int(sys.stdin.readline())

n = int(math.log(h,2)) +1


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

Solution (Python):

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


cnt = 0

n = 1
while n>0:
    cnt+= n
    
    if h>1:
        h = h//2
        n = 2*n
    elif h==1:
        n=0
    

print(cnt)

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

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

for num in range(count):
  attack = attack + 2**num

print(attack)

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


h = int(input())
print(numAttack(h))

Solution (Python):

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

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

Solution (Python):
import math


def InS(): return input()


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


def InI(): return int(input())


H = InI()

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

X = 2**(N + 1) - 1

print(X)

Solution (Python):
import math
H = map(int,input().split())

ans=sum([2**int(1+math.floor(math.log2(s)))-1 for s in H])

print(ans)

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

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

Solution (Python):
import math
h = int(input())
res = 0
node = 1
flag = True
while flag:
    res += node
    h = int(math.floor(h / 2))
    node *= 2
    if h == 0:
        flag = False
print(res)

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

Solution (Python):
import math


H = int(input())

pow_data = 1
pow_count = 0

while H >= pow_data:
    pow_data *= 2
    pow_count += 1

output = 0
tmp = 1
for i in range(pow_count):
    output += tmp
    tmp *= 2
print(output)

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

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

Solution (Python):
n = int(input())
i = 0
ans = 0
while True:
  if n < 2**i:
    print(ans) 
    exit()
  ans += 2**i  
  i += 1

Solution (Python):
H = input()

i = 0
while 2 ** i <= int(H):
  i += 1
print(2 ** i - 1)

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

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

ans = calc(H)
print(ans)

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

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

Solution (Python):


import sys
import math

from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


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


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


H = ii()
print(attack_count(H))

Solution (Python):
x=int(input())
count=0
output=0
i=0
while x>0:
    if(x>=1):
        count=count+2**i
    i=i+1


    x=x/2
print(count)

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

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

Solution (Python):
j = 0

def attack(x):
    global j
    if x == 1:
        j += 1
        return
    elif x % 2 == 1:
        x = x // 2
        j += 1
    else:
        x = int(x / 2)
        j += 1
    attack(x)

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

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

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

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

Solution (Python):
import math

h = int(input())

a = int(math.log(h, 2)) + 1

print(2 ** a - 1)

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

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

for i in range(k + 1):
    total += 2 ** i

print(total)

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

Solution (Python):
import collections

h = int(input().strip())

m = collections.defaultdict(int)
m[h] = 1

count = 0
while 0 < len(m.keys()):
    nm = collections.defaultdict(int)
    for hp, num in m.items():
        if 1 < hp:
            nhp = hp // 2
            nm[nhp] += 2 * num
            count += num
        else:
            count += num
    m = nm

print(count)

Solution (Python):
import numpy as np
H=int(input())
n=int(np.log2(H))+1
print(2**n-1)

Solution (Python):

import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)


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

    return solve(math.floor(x/2)) * 2 + 1

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


    print(solve(H))


if __name__ == "__main__":
  main()

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

H = int(input())

min = f(H)

print(min)

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):
def func(x):
  if x == 1:
    return 1
  else:
    return(2 * func(x//2) + 1)
  
print(func(int(input())))

Solution (Python):






import math
import statistics
import numpy as np
import queue

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

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

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

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

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




h = math.log2(n)
h = math.floor(h)
print(2**(h+1)-1)

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

Solution (Python):

H = int(input())

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

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

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

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

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

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

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

print(2 ** c - 1)

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

count=0
ans=1

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

print(ans)

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

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

Solution (Python):
h = int(input())
c = 0
i = 0
if h == 1:
  print(1)
else:
    while True:
      c+=1
      h = h//2
      if h <= 1:
        break
    print(sum(2**y for y in range(c+1)))

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

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

i = 0
while 2 ** i > H or H >= 2**(i+1):
    i = i +1
print(2**(i+1) -1)

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

count = 0
sum = 0

while n != 0:
  n //= 2
  sum += 2**count
  count += 1
  
print(sum)

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

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

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

n = 0
for i in range(len(hp)- 2):
    n += 2**i
    
print(n)

Solution (Python):
h = int(input())
new_h = h
pow_num = 0
ans = 0
attack = 1
preattack = 1

if h == 1:
  print("1")
  exit()
while(1):
  new_h = new_h//2
  pow_num += 1
  if new_h == 1:
    break
for i in range(pow_num):
  preattack = preattack*2
  attack += preattack
print(attack)

Solution (Python):
h = input()

def myfunc(hp: 'int') -> 'int':
    if(hp == 1):
        return 1
    elif(hp > 1):
        return int(myfunc(hp/2)) * 2 + 1
    return hp


if __name__ == '__main__':
    ans = myfunc(int(h))
    print(ans)

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


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


print(func(H))

Solution (Python):
def attack_count(N):
    if N == 1:
        return 1
    else:
        return 2 * attack_count(N//2) + 1

H = int(input())
print(attack_count(H))

Solution (Python):
import sys
import math

H = int(input())
count = 0

if not 1 <= H or not H <= 10**12:
    print("error:1≤H≤10^12である必要があります")
    sys.exit()

while True:
    if H <= 0:
        break
    H = math.floor(H / 2)
    count = 1 + 2*count
print(count)

Solution (Python):
H = int(input())
if H==1:
  print(1)
elif 2 <= H and H <= 3:
  print(3)
elif 4 <= H and H <= 7:
  print(7)
else:
  for i in range (1,43):
    if 2**(i-1)<=H and H <2**(i):
      print(2**(i)-1)
    else:
      pass

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

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

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

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

n = int(input())
print(f(n))

Solution (Python):
import math
h = int(raw_input())
at = 0
i = 1
while True:
    at+=i
    i = i*2
    if h==1:
        break
    h = int(math.floor(h/2.0))
print at

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

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

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

import math

a = math.log2(h)



b = math.floor(a)



c = 2**(b+1) - 1

print(c)

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

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

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
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 LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

print(ans+1)

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

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

Solution (Python):


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


h = int(input())


print(harf(h))

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

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

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

Solution (Python):
import math

n=float(input())
l=[]
cnt=0
while n >= 1:
    l.append(2**cnt)
    n=math.floor(n/2)
    cnt+=1

print(sum(l))

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

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

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

h = H
attack = []
division = 0
while h >= 1:
    h /= 2
    attack.append(2**division)
    division += 1
print(sum(attack))

Solution (Python):
import numpy as np


H = int(input())
X = int(np.floor(np.log2(H)))
R = 2**(X+1)-1

print(R)

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

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

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

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

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

print(attack(h))

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

atk = 1
sum = 1
while(h != 1):
    h = h//2
    atk *= 2
    sum += atk

print(sum)

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

cnt = 0
num = 1
length = len(str(bin(H)))-2
print(2**length-1)

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

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

Solution (Python):
import numpy as np
import math

N = int(input())

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

x = np.array([2 ** x for x in range(a+1)])

print(x.sum())

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

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

print(ans)

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

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

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

print(ans)

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

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

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

print(Rec(a))

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

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

h = int(input())
print(attack(h))

Solution (Python):
h = int(input())
v = 1
t = v

while True:
    if t >= h:
        break
    v *= 2
    t += v

print(t)

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

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

    print(ans)
    return

if __name__=="__main__":
    main()

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

cnt = 0

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

summery = 0

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

print(summery)

Solution (Python):
from sys import stdin

H=int(stdin.readline())

a=2
cnt=1
if H==1:
  print(1)
else:
  while a<=H :
    a=a*2
    cnt=cnt+1
  print(2**cnt-1)

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

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

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

print(solve_cost(H))

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

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

t = int(math.log2(H))

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

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

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

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

print(ans)

Solution (Python):
from math import log,floor
from sys import stdin
print((2**(floor(log(int(stdin.readline()),2))+1))-1)

Solution (Python):
from sys import stdin
n = int(stdin.readline())
ans = 1; cnt = 1
while n>1:
	n >>=1
	ans += cnt<<1
	cnt <<=1
print(ans)

Solution (Python):
import numpy as np
import math

def resolve():
    n = input()
    m = math.floor(np.log2(int(n)) + 1)
    ans = 0
    for i in range(m):
        ans += 2 ** i

    print(ans)
resolve()

Solution (Python):


N = int(input())
S = 1

while N >= S:
    S *= 2
 
print(S - 1)

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

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

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

    ans = 0
    i = 0

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

    print(ans)

resolve()

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

Solution (Python):
def car(n):
  if n==1:
    return 1
  elif n%2==0:
    return (car(n//2)*2)+1
  else:
    return (car((n-1)//2)*2)+1
  
N=int(input())
print(car(N))

Solution (Python):

from sys import setrecursionlimit

setrecursionlimit(1000000)

H = int(input())


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


print(f(H))

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

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

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

h=int(input())

print(f(h))

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

def Caracal(x):
  if x>1:
    ans=1+Caracal(x//2)*2
  elif x==1:
    ans=1
  return ans

print(Caracal(HP))

Solution (Python):
n=int(input())
import collections
d=collections.defaultdict(int)
import sys
sys.setrecursionlimit(10000)

def luca(n):
    if n in d:
        return d[n]
    if n==1:
        return 1
    else:
        tmp=luca(n//2)*2+1
        d[n]=tmp
        return tmp

print(luca(n))

Solution (Python):
H=int(input())
monsters=[]
monsters.append([1,H])

n=0
a=H
for i in range(40):
  a=a//2
  if a>=1:
    n+=1
  else:
    break

ans=0
for i in range(n+1):
  if monsters[i][1]==1:
    ans+=monsters[i][0]
  else:
    ans+=monsters[i][0]
    monsters.append([2*monsters[i][0],monsters[i][1]//2])

print(ans)

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

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

print(ans+2**cnt)

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

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

print(func(h))

Solution (Python):
import math

h = int(input())
atk = 0
for i in range(int(math.log2(h)) + 1):
    atk += 2 ** i

print(atk)

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

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

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

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

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

a = int(input())
print(ans(a))

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

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

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

i=0
ans=1
while H!=1:
    H=int(H/2)
    i+=1
    ans+=pow(2,i)
print(ans)

Solution (Python):
from math import floor, log2

def solve(n):
    return 2 ** (floor(log2(n)) + 1) - 1

_n = int(input())
print(solve(_n))

Solution (Python):
H = int(input())
num = 1
List = [1]
X = H

for i in range (H):
  if X >= 2:
  	X = X // 2
  	num = num * 2
  	List.append(num)
  else:
    break
    
print(sum(List))

Solution (Python):

import math
H = int(input())
count = 0
while math.floor(H / 2) > 0:
    H = H / 2
    count += 1
count += 1
print(-(1 - 2**count))

Solution (Python):
h = int(input())
attack = 0
monsters = 1
depth = 0
while h > 0:
    if h == 1:
        attack += 2 ** depth
        h -= 1
    else:
        depth += 1
        attack += monsters
        monsters = monsters * 2
        h //= 2
print(attack)

Solution (Python):
import math


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

    
    group = math.floor(math.log(h, 2)) + 1
    ans = 2 ** group - 1
    print(ans)


main()

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

count = 1

while True:
    if n > 1:
        n = n//2
        count += 1
    else:
        break

value = 0
factional = 0.5
for i in range(count):
    factional = factional * 2
    value += factional

print(int(value))

Solution (Python):
h=int(input())
import math
i=int(math.log2(h)-2)
while i<=int(math.log2(h))+2:
  if 2**i<=h<2**(i+1):
    print(2**(i+1)-1)
  i+=1

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

Solution (Python):
import math

n=int(input())
count = 0
sum_count = 0

while n > 0:
    if n == 1:
        n = n - 1
        sum_count = sum_count + 2**(count)
    else:
        n = math.floor(n / 2)
        count += 1
        sum_count = sum_count + 2**(count-1)

print(sum_count)