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

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = 998244353
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    
    H = Scanner.int()
    ans = 0
    tmp = 1
    while H > 1:
        H //= 2
        ans += tmp
        tmp *= 2
    ans += tmp
    print(ans)
    return


if __name__ == "__main__":
    main()

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

count = 0
monster = 1
while h > 0:
    count += monster
    h //= 2
    monster *= 2
print(count)

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

Solution (Python):

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

Solution (Python):
from sys import stdin
import math
def main():
    n = int(stdin.readline().strip())
    x = int(math.log(n,2))
    print( (2**(x+1))-1)
main()

Solution (Python):

if __name__ == '__main__':
    
    

    h = int(input())
    if h == 0:
        print("0")
        exit()
    monster = 1
    count = 0
    while h > 0:
        count += monster
        h //= 2
        monster *= 2
    print(count)

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

Solution (Python):
import math 

H = int(input())

number1 = math.floor(math.log(H, 2))

A = 0

for i in range(number1+1):
    A += 2**i
print(A)

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

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

ans = f(H)

print(ans)

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

Solution (Python):
import math

def main():
    H = int(input())
    print(2**(math.floor(math.log(H,2))+1)-1)
          
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    H = int(input())
    c = 0
    ans = 1
    while H != 1:
        H = H//2
        c += 1
        ans += 2**c
    print(ans)
          
if __name__ == "__main__":
    main()

Solution (Python):
def calc(num):
  if num == 1:
    return 1
  else:
    return calc(num // 2)*2 + 1

print(calc(int(input())))

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

ans = 0
cnt = 1

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

print(ans)

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

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

    ans = 0
    add = 1

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

main()

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

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

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

import math

def A(n):
    if n > 1:
        return A(math.floor(n/2))*2+1
    else:
        return 1

print(A(H))

Solution (Python):
import sys
h = int(input())
if h == 1:
    print(1)
    sys.exit(0)

cnt = 0
while h > 1:
    h = h//2
    cnt+=1
s = 0
for i in range(cnt+1):
    s += 2**i
print(s)

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

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

print(f(a))

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

while True:
    if h == 1:
        break
    else:
        h = h//2
        i += 1

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

print(ans)

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

import math
i = 0
ans = 0
while h >= 1:
    h = math.floor(h / 2)
    ans += 2 ** i
    i += 1

print(ans)

Solution (Python):
from math import floor
import sys
sys.setrecursionlimit(10000000)
 
h = int(input())
 
def f(n):
    if n == 1:
        return 1
    else:
        return f(floor(n/2)) * 2 + 1
 
print(f(h))

Solution (Python):
from math import floor
import sys
sys.setrecursionlimit(1000)
 
h = int(input())
 
def f(n):
    if n == 1:
        return 1
    else:
        return f(floor(n/2)) * 2 + 1
 
print(f(h))

Solution (Python):
from math import floor
import sys
sys.setrecursionlimit(1000)
 
h = int(input())
 
def f(n):
    if n == 1:
        return 1
    else:
        return f(floor(n/2)) * 2 + 1
 
print(f(h))

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

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

Solution (Python):
def rec_count(num):
    if num == 1:
        return 1
    elif num == 2:
        return 3
    elif num == 3:
        return 3
    else:
        split = num // 2
        return 1 + 2 * rec_count(split)

h = int(input())
print(rec_count(h))

Solution (Python):
import math

H = int(input())

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

print(ans)

Solution (Python):
h = int(input())
n = 100
for i in range(100):
    if pow(2,i) <= h < pow(2,i+1):
        print(pow(2,i) + pow(2,i)- 1)
        break
    
    elif h == pow(2, i+1):
        print(pow(2, i+1) + pow(2,i+1) - 1)
        break
    
    else:
        continue

Solution (Python):

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

H = int(read().strip())

def solve(h):
    if h == 1:
        return 1
    
    new_h = int(h / 2)
    return (2 * solve(new_h)) + 1

answer = solve(H)
print(answer)

Solution (Python):
import math

H_point = int(input())
t = math.floor(math.log2(H_point))
t = 2**(t+1)-1
print(t)

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

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

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

def atakku(h, c):
  c += 1
  if h != 1:
    hh = math.floor(h / 2)
    c = atakku(hh, c*2)
  return c

N = atakku(H, 0)
print(N)

Solution (Python):
H = int(input()) 
atCount = 0 
n = 0 


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

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

Solution (Python):
import sys

input = sys.stdin.buffer.readline


def main():
	
	
	
	H=int(input())
	
	res = 0
	en = 1
	while H:
		res += en
		H //= 2
		en *= 2

	print(res)

main()

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

Solution (Python):
from math import log

H=int(input())

h=int(log(H,2))

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

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

def func_ans(x):
  sum = 0
  if x == 1:
    return 1
  else:
    return func_ans(x//2) + func_ans(x//2) + 1

ans = 0

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

Solution (Python):
H = int(input())
ans = 1
H //= 2
i = 1

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

print(ans)

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

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

print(ans)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    h = I()
    k = h.bit_length()
    print((1 << k) - 1)
    return



if __name__ == "__main__":
    solve()

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

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

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

print(ans)

Solution (Python):

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

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

pow = 1
res = 0
while (h!=1):
    h=math.floor(h/2)
    pow+=1
for i in range(pow):
    res += 2**i
print(res)

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

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

Solution (Python):
[H]=list(map(int, input().split()))

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

Solution (Python):
H = int(input())
x = 0
list_1 = []
for i in range(H+1):
    if H == 1:
        list_1.append(x)
        break
    else:
        H = H // 2
        list_1.append(x)
        x += 1
list_2 = list(map(lambda a: 2**a,list_1))
print(sum(list_2))

Solution (Python):
def main():
	H = int(input())
	cnt = 0
	if H==1:
		print(1)
		exit()
	while 1:
		if H==1:
			break
		else:
			H = H//2
			cnt += 1
	ans = 0
	for i in range(cnt):
		ans += 2**i
	ans += 2**(i+1)
	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
n = int(input())
m = 1
while n > m:
  m *= 2
  m += 1
print(m)

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

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

Solution (Python):
from collections import deque
def son(generation,life):
    if life > 1:
        nextson = (generation+1, life//2)
    else:
        nextson = (0, 0)
    return nextson
    
def generationnum(generation):
    return 2**generation

def bfs(startlife,startgeneration):
    queue = deque([(startgeneration,startlife)])
    totalnum = 0
    while queue:
        label = queue.popleft()
        if label == (0, 0):
            break
        totalnum += generationnum(label[0])
        queue.append(son(label[0],label[1]))
    return totalnum
            
if __name__ == '__main__':
    print(bfs(int(input()), 0))

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

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

Solution (Python):
H = int(input())
 
def attackCount(hitpoint):
    if hitpoint == 1:
        return 1
    elif hitpoint > 1:
        return 2*attackCount(hitpoint//2)+1
    else:
        raise ValueError
 
 
print(attackCount(H))

Solution (Python):
import math

h = int(input())

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

print(2**count*2-1)

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

num = 1
res = 1

if H > 1:
    while (num * 2) <= H:
        num = num * 2
        res = num * 2 - 1

print(res)

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

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

print(pow(2, c)-1)

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

Solution (Python):
def hoge(n, cnt=0):
    if n == 0:
        return cnt
    else:
        return hoge(int(n/2), 2 * cnt + 1)
      
def one_int():
    return int(input())
  
  
print(hoge(one_int()))

Solution (Python):

H = int(input())


def attackCount(hitpoint):
    if hitpoint == 1:
        return 1
    elif hitpoint > 1:
        return 2*attackCount(hitpoint//2)+1
    else:
        raise ValueError


print(attackCount(H))

Solution (Python):
import sys
from math import floor, log2



h = int(input())
power = int(floor(log2(h))) + 1
print((1 << power) - 1)

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

print(2**n-1)

Solution (Python):
def calc(x):
  if x == 0:
    return 0;
  return 1 + calc(x // 2) * 2

h = int(input())

print(calc(h))

Solution (Python):
def input_int():
    return int(input())

def suss(num):
  result = 2
  while num > 1:
    num = num // 2
    result = result * 2
  return result - 1

h = input_int()
print(suss(h))

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

Solution (Python):
def find_minimum_attack_time(health):
    if health == 1:
        return 1
    return 2 * find_minimum_attack_time(health // 2) + 1


if __name__ == '__main__':
    print(find_minimum_attack_time(int(input())))

Solution (Python):
import math

h = int(input())

c = 0

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

print(attack_n(h))

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


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


print(dfs(h))

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

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

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

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

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

div_num = 0
attack_num = 0
if H == 1:
	print("1")
else:
	while True:
		H = H // 2
		attack_num += 1
		if H == 1:
			break
	
	print(sum([2**i for i in range(attack_num+1)]))

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

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

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

n1 = 2 ** k - 1
n2 = 2 ** k

n = n1 + n2

print(n)

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

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

print(atk(H))

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

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

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

Solution (Python):
import math
def count_attack(k):
  if k==1:
    return 1
  else:
    return 2*count_attack(math.floor(k/2)) +1
h = int(input())
print(count_attack(h))

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

Solution (Python):
h, = (int(x) for x in input().split())

n = len(format(h, 'b'))
k = '1'
for i in range(n):
    k += '0'

print(int(k, 2) - 1)

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

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

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

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

Solution (Python):



h = int(input())

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

print((2 ** i) - 1)

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

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


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

Solution (Python):
H = int(input())
from math import floor
total = 0
counter = 1
while H > 0:
  H = floor(H/2)
  total += counter
  counter *= 2
print(total)

Solution (Python):
import math

H = int(input())

ans, mul = 0, 1
while H > 1:
    H = math.floor(H / 2)
    ans += mul
    mul *= 2

print(ans + mul)

Solution (Python):
import sys
input = sys.stdin.readline
H = int(input())
import math
K = int(math.log2(H))
print(2 ** (K+1) - 1)

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

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

Solution (Python):
import math

N = int(input().strip())
cnt = 1
while N>1:
  N = math.floor(N/2)
  cnt += 1

print(int(math.pow(2,cnt)-1))

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

Solution (Python):

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()

def killTime(H):
    if H ==0:
        return 0
    if H==1:
        return 1
    return 1+2*killTime(H//2)

def main():
    return killTime(iRaw())


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

Solution (Python):


import math

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

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

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

Solution (Python):


import math

H = int(input())
n = math.floor(math.log2(H))
print((2**(n+1))-1)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h = I()
    def f(i):
        if i < 1:
            return 0
        return f(i//2) * 2 + 1

    return f(h)


print(main())

Solution (Python):
import math

H = int(input())

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

Solution (Python):
import math

H = input()
m = math.ceil(math.log2(int(H) + 1))
n = int(math.pow(2, m) - 1)
print(n)

Solution (Python):
import math


log2=math.log2
H=int(input())
n=math.floor(log2(H))
print(2**(n+1)-1)

Solution (Python):
import math

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

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

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

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

depth = 0
end = 2
while h >= end:
    depth += 1
    end *= 2

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

Solution (Python):

import sys
import math

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

Solution (Python):

h = int(input())

ans = 0
count = 1
while h != 1:
    h = h // 2
    ans += count * 1
    count *= 2
print(ans + count)

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

print(s + 1)

Solution (Python):
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def D():
    H = wczytaj_liste()[0]
    wykladnik = 0
    while 2**wykladnik <= H:
        wykladnik += 1
    odp = 2**wykladnik - 1
    print(odp)

D()

Solution (Python):
from math import floor
H = int(input())
tmp=1
ans=0
while H>0:
  H = floor(H/2)
  ans+=tmp
  tmp*=2
print(ans)

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

count = 0
n = H
while n // 2 >= 1:
    n = n // 2
    count += 1
    
ans = (2**count-1)*2+1
print(ans)

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

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

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

Solution (Python):
import sys
import math

h = int(sys.stdin.readline())
count=0

flr = int(math.log(h,2))
for i in range(flr+1):
  count+=2**i
print(count)

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

Solution (Python):
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('d1.in')


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve0():
    h = read_int()
    m = 1
    c = 1
    while h > 1:
        h = h//2
        m *= 2
        c += m
    return c

def solve():
    h = read_int()
    m = 1
    c = 0
    while h >= 1:
        c += m
        h = h//2
        m *= 2
    return c


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):



import math

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

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

if __name__ == "__main__":
    main()

Solution (Python):
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    h = int(input())
    i = int(2*2**math.floor(math.log2(h))-1)
    print(i)

    
    
    
    
    
    

    
    
    
    
    


if __name__ == '__main__':
    main()

Solution (Python):
import math

h = int(input())
l = int(math.log(h, 2))

ans = math.pow(2, l+1) - 1
print(int(ans))

Solution (Python):

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

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

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

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

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

print(solve(int(input())))

Solution (Python):
h=int(input())
bin_str = format(h, 'b')
cost = 0
x = [1,0] 
l = len(bin_str)
if h >= 2:
  for i in range(0,l-1):
    cost = cost + (x[int(bin_str[l-i-1])])*2**i
print(h+cost)

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

print(count - 1)

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



a = 1
r = 2
n = 1 + int(math.log2(H))

print(int(a*(1-r**n)/(1-r)))

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

print(count - 1)

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

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

Solution (Python):
H=int(input())
step=0;
while H>0:
    H=H//2
    step+=1 
print(pow(2,step)-1)

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

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

print(rec(H))

Solution (Python):
def at_cal(hp, count):
	if hp > 1:
		count += 1
		hp //= 2
		count *= 2
		return at_cal(hp, count)
	else:
		return count + 1

hp = int(input())
print(at_cal(hp, 0))

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    H = I()
    div_cnt = 0
    ans = 0
    while H > 0:
        ans += (1 << div_cnt)
        H = H // 2
        div_cnt += 1
    print(ans)
main()

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

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

Solution (Python):
import math

def main():
    H = int(input())
    ans = 2 ** (int(math.log(H, 2)) + 1) - 1
    print(ans)

if __name__ == '__main__':
    main()

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):
print(2**(len(bin(int(input()))[2:]))-1)

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

while h>=1:

    h=h/2
    s= s + 2**n
    n+=1
    
    
print(s)

Solution (Python):
line=input()
line=line.split()
num=float(line[0])
num2=1
count=1
if int(line[0])<=1:
    print(1)
else:
    while 1<num:
        num = int(num/2)
        num2*=2
        count+=num2
    print(count)

Solution (Python):
import numpy as np
H=input()
H=int(H)

def count(H):
	count=1
	while True:
		if int(H/2)==0:
			break
		else:
			H=int(H/2)
			count+=1
			continue
	return count

A=0
for i in range(int(count(H))):
	A+=2**i
			
print(A)

Solution (Python):
import math

def sn(n):
    return pow(2, n+1) - 1

h = int(input())

cnt = 0

if(h==1):
    print(1)
else:
    lim = int(math.log2(h))
    print(sn(lim))

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

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

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

H=int(input())

count=f(H)
print(count)

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


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

print(f(H))

Solution (Python):
res = 0
num_enemy = 1
n = int(input())
while True:
    res += num_enemy
    if n==1:
        break
    num_enemy *= 2
    n = n//2
print(res)

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

n=math.floor(math.log(n,2))
n=2**n
print((2*n)-1)

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

count  = 0

while hp > 0:
  count += 1
  if hp == 1:
    hp -= 1
  else:
    hp = hp // 2
    
a = 2 ** count -1
print(a)

Solution (Python):
def calc_count(n):
    if n == 1:
        return 1

    return 2 * calc_count(n//2) + 1


H = int(input())
ans = calc_count(H)
print(ans)

Solution (Python):
import math

h = int(input())

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

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

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

    if H == 0:
        break

print(ans)

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

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

while hp > 0:
    cnt += 1
    if hp == 1:
        hp -= 1
    else:
        hp //= 2

print(2**cnt -1)

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

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

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

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