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):
def c(h, memo):

    if h == 1:
        return 1

    if h in memo:
        return memo[h]

    num_of_attacks = 1 + c(h // 2, memo) + c(h // 2, memo)
    memo[h] = num_of_attacks
    return num_of_attacks


def main():
    
    h = int(input())
    
    memo = {}
    res = c(h, memo)
    print(res)


main()

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

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

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

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

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

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

print(attack+pow(2,i))

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

Solution (Python):
import numpy as np

H = int(input())

candidate = []
for i in range(49):
    candidate.append(2**i)

candidate_array = np.array(candidate).reshape(-1, 1)

for i in range(49):
    if candidate_array[i, 0] > H:
        candidate_select = candidate_array[:i, 0]
        print(np.sum(candidate_select))
        break

Solution (Python):
H = int(input())
import math
if not math.log(H, 2).is_integer():
  H = 2 ** math.floor(math.log(H, 2))

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

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

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

Solution (Python):
import math

H = int(input())

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

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

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

print(result)

Solution (Python):

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

Solution (Python):
H = int(input())
Point=1
for i in range(300):
    if H>1:
        H=H//2
        Point=Point+Point+1


    else:
        print(Point)
        break

Solution (Python):
H=float(input())
layer=[1]
i=0
count=0
HP=int(H/2)
if HP<=0:
    count+=layer[0]
    print(count)
else:
    count+=layer[0]
    while HP>0:
        i+=1
        layer.append(layer[i-1]*2)
        count+=layer[i]
        HP=int(HP/2)
    print(count)

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

Solution (Python):
n=int(input())
a=[2**i for i in range(50)]
import math
x=0
while n>1:
    n=math.floor(n/2)
    x+=1
print(int(4*(2**(x-1))-1))

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

counter=1
ans=0
while H!=1:
    H=int(H/2)

    counter=counter*2

    ans+=counter






print(ans+1)

Solution (Python):
num = int(input())
i = 0
ans_L = [1]
while num!=1:
    num = num//2
    i += 1
    ans_L.append(2**i)

print(sum(ans_L))

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

n = 1

def calc(h,n):
    a = h//2
    if a==1:
        n += 2
    else:
        n += 2*calc(a,n)
    return n


if H == 1:
    print(1)
else:
    ans = calc(H,n)
    print(ans)

Solution (Python):
from math import log2, pow

h = int(input())
n = int(log2(h))
print(sum([2 ** e for e in range(0, n + 1)]))

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

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

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

print(result)

Solution (Python):
h=int(input())
for i in range(40):
    if 2**i<=h<2**(i+1):
        print(2**(i+1)-1)

Solution (Python):
from math import floor

h = int(input())

ans = 1
i = 0
while h != 1:
    i += 1
    h = floor(h/2)
    ans += 2**i

print(ans)

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

ans = 1

loop = math.floor(math.log2(h))

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

print(ans)

Solution (Python):


from collections import deque
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  H = inputInt()
  cnt = 0
  ans = 0
  while H:
    H = H >> 1
    ans += 2 ** cnt
    cnt += 1

  return ans


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

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


import numpy as np

cnt=0
for i in range(100):
    if H<2**(i+1):
        break
    else:
        cnt+=1
        
if cnt == 0:
    print(1)
else:    
    print(np.sum([2**i for i in range(cnt+1)]))

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

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

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

print(count)

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





i = 0
ans_L = [1]
while h!=1:
    h = h//2
    i += 1
    ans_L.append(2**i)

print(sum(ans_L))

Solution (Python):
h = int(input())
list_1 = []
ans = 0
cnt = 0
if h == 1 :
  ans = 0
else :
  cnt += 1
  list_1.append(cnt)
  while h // 2 != 1: 
    cnt += 1
    list_1.append(cnt)
    h = h // 2

for i in list_1 :
  if i == 1:
    ans += 2
  else :
    ans += 2**i

print(ans+1)

Solution (Python):
import math
h = int(input())
c = 0
while h > 1:
    h /= 2
    c += 1
if h == 1:
    print(int("1"*(c+1),2))
else:
    print(int("1"*c,2))

Solution (Python):
import math
h=int(input())
h_now=h
num_now=1
ans=0
for i in range(50):
    if h_now==1:
        break
    else:
        h_now=math.floor(h_now/2)
        ans+=num_now
        num_now=num_now*2

ans+=num_now
print(ans)

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

sig = 0
for i in range(count2):
    sig += 2 ** i

ans = 2**count2 + sig
print(ans)

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

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

for i in range(10000000000):
  if 2**i>h:
    print(2**i-1)
    break

Solution (Python):
import math

H = int(input())

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

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

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

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

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

ans = 1
while count > 0:
    ans = ans + 2 ** count
    count -= 1

print(ans)

Solution (Python):
h=int(input())
h1=h
icnt=0
for i in range(1000):
    h1=h1//2
    icnt=icnt+1
    if h1<1:
        break
    
s=int(2**icnt)-1
print(s)

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

res = 0
k = 0

while(H != 0):
    H = (int)(H/2)
    res += 2 ** k
    k += 1

print(res)

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

for i in range(1, 41):
    if (2 ** i) > hp:
        n_bi = i - 1
        break

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

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

print(2 ** count - 1)

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

import math

if h == 1:
    print(1)

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

    gsum = 1

    for x in range(n_attacks):
        gsum += 2 ** (x + 1)
        
    print(gsum)

Solution (Python):
def rec(l):
    if l<=0:
        return 0
    if l==1:
        return 1
    else:
        return 1+2*rec(l//2)
x=int(input())
print(rec(x))

Solution (Python):
n = int(input())
s = str(bin(n))[2:]
l = len(s)
print(2**l-1)

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

Solution (Python):
H = input()

def attack_sum():
	X = H
	number_attack = 0
	while X > 0:
		number_attack *= 2
		number_attack += 1
		X = X // 2
	return number_attack		

ans = attack_sum()
print(ans)

Solution (Python):
from sys import stdin
import math


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

    hp = h
    num_enemy = 1
    num_attack = 0
    while hp >= 1:
        hp, num_enemy, this_attack = attack(hp, num_enemy)
        num_attack += this_attack
    return num_attack


def attack(enemy_hp, num_enemy):
    num_attack = num_enemy
    enemy_hp = math.floor(enemy_hp / 2)
    num_enemy *= 2
    return enemy_hp, num_enemy, num_attack


if __name__ == '__main__':
    input_line = stdin.readline().rstrip()
    ret = main(input_line)
    print(ret)

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

for i in range(H):
    if 2 ** i > H:
        break
    pow_num += 1

attack_num = 0
for i in range(pow_num):
    attack_num += 2 ** i

print(attack_num)

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

roop=int(math.log2(H))

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

Solution (Python):
h = int(input())
tem = 1
while h/2 > 1:
    tem+=1
    h = h/2
result = 1
if h==2:
    for i in range(1,tem+1):
        result += 2**i
else:
    for i in range(1,tem):
        result += 2**i
print(result)

Solution (Python):
def enemy_counter(H,T):
    if H==1:
        T=1
    else:
        T+=2*enemy_counter(H//2,T)+1
    return T

H=int(input())
print(enemy_counter(H,0))

Solution (Python):

h = int(input())

count = 1
result = 1

while True:
    if h >= 2 ** count:
       result += 2 ** count
       count += 1
    else:
        break

print(result)

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

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

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

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

print(result)

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

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

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

Solution (Python):
h = int(input())
h = format(h, 'b')
t = h.find('1')
l = len(h)
ans = 2 ** l - 1
print(ans)

Solution (Python):
import sys

H = int(input())

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

h = 1

while(True):
  if 2**h <= H < 2**(h+1):
    break

  h += 1

ans = 3

if h == 1:
  print(ans)
  sys.exit()

for k in range(1, h+1):
  if k == 1:
    continue

  ans += 2**k

print(ans)

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

Solution (Python):


H = int(input())

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

print(ans)

Solution (Python):
h = [int(input())]
a = 1
x = False
while(x == False):
  if h[0] < 1:
    x = True
    break
  h = list(map(lambda x: x / 2, h))
  a = a*2
print(a-1)

Solution (Python):
import math
import numpy as np

H = int(input())

for i in range(1000):
  if 2**i > H:
    num = i-1
    break
dp = 1
for j in range(num):
  dp = 2*dp+1
print(dp)

Solution (Python):
import math

H = int(input())

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

root = math.floor(math.log2(H))

total = 1

mem = [1 for _ in range(root+1)]

for i in range(1, root+1):
  mem[i] = mem[i-1] * 2
  total += mem[i]
  
print(total)

Solution (Python):


import math

h = int(input())
if h > 1:
    x = math.floor(h/2)
    n = 2
    count = n
    while x > 1:
        x = math.floor(x/2)
        n = n*2
        count += n
        
    print(count+1)
else:
    print(1)

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

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

print(result)

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

for i in range(41):
    if 2**(i+1) > h and h >= 2**i:
        n = i + 1
        break
print(2**n - 1)

Solution (Python):

from math import log2,floor
n=int(input())
k=floor(log2(n))
if int(k)==k:
    print(pow(2,k+1)-1)
else:
    print(pow(2,k)-1)

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

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

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


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

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

ch=1
total=1

while 1:
    if h < ch:
        break
    else:
        ch*=2
        total+=1

print(ch-1)

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

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

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

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

Solution (Python):

import sys


def solve(H: int):
    ans = 2 ** f(H) - 1
    print(ans if H > 1 else 1)
    return


def f(H, dep=1):
    half_h = H // 2
    dep += 1
    return f(half_h, dep) if half_h > 1 else dep



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):
H = int(input())

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


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

print(ans)

Solution (Python):
def Step(i):
	if i == 1 :
		return 1
	a = 2 * Step(i//2)
	return a+1

H = int(input())
print(Step(H))

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

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

print(func(H))

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

H = int(input())

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

print(ans)

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

count = 0
enemy = H
ans = 0

while(enemy >= 1):
    enemy /= 2
    count += 1

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

print(ans)

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

a = h
num = 0
total = 0

while a >= 1:
  if num == 0:
    num += 1
  else:
    num = num * 2
  total += num
  a = a // 2

print(total)

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

result=1
count=1

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

print(2**count-1)

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

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

print(result)

Solution (Python):
import math

h = int(input())
h_list = [h]

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

print(2**i - 1)

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

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

print(result)

Solution (Python):
import math

h = int(input())


def nearpow2(n):
    k = int(math.log2(n))
    return k

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

Solution (Python):
import math
def twosq(no):
  n = int(math.log2(no))
  tot = 0
  for i in range(1, n+1): tot+=2**i
  return tot+1

x = int(input())
print(twosq(x))

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

if __name__ == "__main__":
    main()

Solution (Python):
a=int(input())
pow_count = 0
count = 1
if a == 1:
    print(count)
else:
    while a >= 2:
        a /= 2
        pow_count += 1

    for i in range(pow_count):
        count = count * 2 +1
    print(count)

Solution (Python):
h=int(input())
count=1
ans=1
v=h
import math
while True:
    temp=math.floor(v/2)
    if temp==0:
        
        
        
        break
    v=temp
    ans+=1
    
print(int((1-2**(ans))/(1-2)))

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

def hantei(X, N):
    if X != 1:
        X_new = np.floor(X/2)
        flag = True
    else:
        X_new = 0
        flag = False
    return X_new, N*2, flag

flag = True
N = 1
count = 0
while flag:
    count += N
    X, N, flag = hantei(X, N)     
print(count)

Solution (Python):
H = int(input())
c = 1
tf = True
while tf:
    if H//2 >= 1:
        c += 1
        H = H//2
    else:
        tf = False
print(2**c-1)

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

Solution (Python):



h = int(input())

dp = {}
dp[1] = 1


def f(x):
    if x in dp:
        return dp[x]
    if x == 1:
        return 1
    tmp = f(x // 2) + 1
    dp[x] = tmp
    tmp += tmp - 1
    return tmp


print(f(h))

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

Solution (Python):
h = int(input())
from math import log2
print(sum([2**n for n in range(int(log2(h))+1)]))

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

Solution (Python):
import math

H = int(input())

cnt = 0
p = 0
r = 0
h = H
while h > 1:
    p = 2 ** r
    r += 1
    cnt += p
    h = math.floor(h / 2)

p = 2 ** r
cnt += p
print(cnt)

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

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

d = {}
d = {1:1}
def f(n):
    if(d.get(n) != None):
        return d[n]
    buf = f(int(n/2)) + f(int(n/2)) + 1
    d[n] = buf
    return buf

print(f(H))

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

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

print(helper(H))

Solution (Python):
import math

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

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

print(result)

Solution (Python):
import math
N=int(input())
n=math.floor(math.log2(N))

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

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

ans = 0

for i in range(100):
    if(H < 2**i):
        max_range = i
        break
    ans += 2**i

print(ans)

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

import math

n=math.ceil(math.log2(H+1))
m=2**(n-1)
ans=2*m-1
print(ans)

Solution (Python):
a = int(input())
i = 0
j = 0

while a != 0:
    a = a // 2
    j += 2**i
    i += 1

print(j)

Solution (Python):
import math

H = int(input())
x = 0
buf = 1
for i in range(60) :
    if 2**i <= H and H < 2**(i+1) :
        x = i
        break

for j in range(x) :
    buf = 2*buf+1

print(buf)

Solution (Python):
import math

h = int(input())
cnt = 0
x = h

while x > 1:
    x = math.floor(x/2)
    cnt += 1

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

Solution (Python):
a = int(input())
s = str(bin(a))[2:]

print(2**len(s)-1)

Solution (Python):
if __name__=="__main__":
    h = int(input())
    
    cnt = 0
    cnt_div = 0
    while h > 1:
        h = int(h/2)
        cnt += 2**cnt_div
        cnt_div += 1
        

    print(cnt + 2**cnt_div)

Solution (Python):
N = int(input())
for k in range(40):
    if N >= 2**k and N < 2**(k+1): 
        print(2**(k+1)-1)

Solution (Python):
H = int(input())
num = 1
ans = 1
if H == 1:
    ans = 1
else:   
    for _ in range(50):
        H //= 2
        num *= 2
        ans += num
        if H == 1:
            break
print(ans)

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

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

print(pow(2, cnt+1)-1)

Solution (Python):
def divide(a):
  count = 0
  ans = 1
  while int(a/2) != 0:
    count += 1
    ans += 2**count
    a /= 2
  return ans

h = int(input())
print(divide(h))

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


n = int(math.log2(H))

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

print(ans)

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

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

  for j in range(cnt+1):
      s += 2 ** j

  print(s)

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


for x in range(10000000000):
    if h < 2 ** x:
        print((2 ** x) - 1)
        break

Solution (Python):
def main():
    h = int(input())
    summ = 0
    bun = 1
    hh = h
    while(True):
        if hh <= 1:
            summ += bun
            break
        else:
            hh  = hh // 2
            summ += bun
            bun *= 2
    print(summ)

if __name__ == "__main__":
    main()

Solution (Python):
import math
def touhi(a,r,n):
    return a*(pow(r, n) - 1)//(r-1)
H = int(input()) 
n = math.floor(math.log2(H))+1
print(touhi(a=1, r=2, n=n))

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

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

a=1
b=0
ans=0
for i in range(1,41):
       if h<a:
              break
       ans+=a
       a=a*2
       b+=1
print(ans)

Solution (Python):
n = int(input())
a=1
z=0
while a<=n:
  a*=2
  z+=1
c=0

for i in range(0,z):

  c+=2**i
print(c)

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

l = 1
num = 0

while(H>=1):
        num+=l
        H = H//2
        l*=2

print(num)

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

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

if h >= 2:
  for i in range(10**12):
    h = h // 2
    if h == 1:
      break
  ans = 0
  for j in range(i+2):
    ans += 2**j
  
  print(ans)
else:
  print(h)

Solution (Python):
resd = {}
def A(h):
    if h == 1:
        return 1
    else:
        if h in resd:
            return resd[h]
        else:
            resd[int(h/2)] = A(int(h/2))*2+1
            return resd[int(h/2)]

H = int(input().strip())
print(A(H))

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

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

    if H==1:
        break
while bycount!=0:
    ans+=2**bycount
    bycount=bycount-1

print(ans)

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

lists = []
lists.append([N])

index = 1 * 2
point = N // 2
sum = 1
while point != 0:
  sum = sum + index
  index = index * 2
  point = point // 2

print(sum)

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

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

print(ans)

Solution (Python):
import math

def solve(h):
    devide = math.floor(math.log2(h))
    if h == 1:
        return 1

    if devide == 1:
        return 3
    if devide >= 2:
        num_of_ones = 2 ** devide


        return num_of_ones + sum_of_touhi(devide,1,2)

def sum_of_touhi(n,a,r):
    return ((a * ((r ** n) - 1)) // (r - 1))




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

if __name__ == '__main__':
    main()

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

attack = 0
monsters = 1
while H > 1:
    H = math.floor(H / 2)
    monsters *= 2
attack += (monsters * 2)
attack -= 1
print(attack)

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

Solution (Python):
H = 0
num = 1
count = 0

H = int(input())

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

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

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

print(result)

Solution (Python):
H=int(input())
import math
count=1
j=0
a=True

while a==True:
    if math.floor(H/2)!=0:
        H=math.floor(H/2)
        count=count+1
    else:
        a==False
        break

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

print(j)

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

count = 0

while start != 0:

    if start % 2 == 0:
        tmp = start / 2
        
    else:
        tmp = (start - 1) / 2
    
    start = tmp
    count += 1


print(2**(count) - 1)

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

ans = int(0)

for i in range(100000):
  n = 2**i
  if n > h:
    ans = 2**i - 1
    print(ans)
    break

Solution (Python):
from math import floor,log2
h = int(input())
d = floor(log2(h))
c = 1
for i in range(0,d):
  c += 2 ** (d-i)

print(c)

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

Solution (Python):
import math

H = int(input())

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

Solution (Python):

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

Solution (Python):
def num_attack(H, N):
  if(H == 1):
    N += 1
  else: 
    N += 2*num_attack(int(H/2),N)
    N += 1
  return N

H = int(input())
N = num_attack(H, 0)
print(N)

Solution (Python):
h = int(input())
if h==1:
    print(1)
u=2
o=4
for i in range(10*5):
    if u<=h<o:
        print(o-1)
        exit()
    else:
        u=u*2
        o=o*2

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    H = int(input())

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


main()

Solution (Python):
import math

h = int(input())
cnt = 0
depth = 0

while True:
  if h == 1:
    cnt += 2**depth
    break
  else:
    cnt += 2**depth
    depth += 1
    h = math.floor(h/2)

print(cnt)

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

a = 0
c = 0

while h > 0:
    h = int (h/2)
    a = a + 1
    c = c + 2**(a-1)

print (c)

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

Solution (Python):
def calc_dan(h):
    hh = h
    dan = 0
    while hh > 1:
        hh = hh // 2
        dan += 1
    return dan

def main():
    H = int(input())
    dan = calc_dan(H)
    answer = 1
    for i in range(1, dan + 1):
        answer += (2 ** i)
    print(answer)

main()

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

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

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

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

print(sum)

Solution (Python):

import sys

def caracal(H,count,separate_number):
	if H == 1:
		return count
	else:
		H = int(H/2)
		count = count + (separate_number*2)
		
		separate_number = separate_number * 2 
	return caracal(H,count,separate_number)




H = int(input())
print(caracal(H,1,1))

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

Solution (Python):
def convert_2(num):
      
    count = 0

    while (num >= 1):
        num /= 2
        count += 1
    
    return(count)

HP = int(input())
cnt = convert_2(HP)
answer = 2**cnt - 1
print(answer)

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

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

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

print(result)

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

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

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

count = 0
while True:
    if H != 1:
        H = H // 2
        count += 1
    else:
        break

final_monster_num = 2 ** count
ans = final_monster_num * 2 - 1 

print(ans)

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

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

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

print(ans)

Solution (Python):
import math
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    a = int(math.log2(h))
    cnt = 2 **a
    ans = (1-2**a)//(1-2)
    print(ans+cnt)
    
if __name__=='__main__':
    main()

Solution (Python):
def main():
    h = int(input())
    flag = True
    num = h
    count = 0

    while flag:
        count += 1
        num = int(num / 2)
        if num == 0:
            flag = False

    print(2 ** count - 1)

if __name__ == '__main__':
    main()

Solution (Python):
import math

h = input()
h = int(h)

n = 1
for i in range(math.floor(math.log2(h))):
  n += 2 ** (i+1)

print(n)

Solution (Python):

h = int(input())

temp = 0
for i in range(1, 50):
    temp = 2**i
    if temp <= h:
        continue
    else:
        N = i
        break


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

Solution (Python):
import math

h = int(input())
num = int(math.log2(h))

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

print(2**count_dev2 - 1)

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

Solution (Python):
n=len(bin(int(input())))-3
if n==0:
    print(1)
elif n==1:
      print(3)
else:
    a=1
    for i in range(1,n+1):
        a+=2**i
    print(a)

Solution (Python):
import math
h = int(input())
if h == 1:
 print(1)
else:
 cnt=0
 while True:
  cnt+=1
  h=math.floor(h/2)
  if (h/2) < 1:
   cnt+=1
   break
 sum=0
 for i in range(cnt):
  sum=sum + (2**i)
 print(sum)

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

if H==1:
  print(1)
else:
  
  if H%2==1:
    H = H-1

  from math import log2
  deep = int(log2(H))+1
  ans = 0
  for d in range(0,deep):
    ans += 2**d

  print(ans)

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

Solution (Python):
i=int(input())
nest=1
a=0
p=i
if p==1:
  print(1)
else:
  for k in range(50):
    nest+=1
    p=p//2
    if p==1:
      break
  a=(2**nest)-1
  print(a)

Solution (Python):
import sys
import math

input = sys.stdin.readline

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


if __name__ == "__main__":
    main()

Solution (Python):
h=int(input())
beki = 0
sum_list = []
while 2 ** beki <= h:
  sum_list.append(2 ** beki)
  beki += 1
  
print(sum(sum_list))

Solution (Python):

h=int(input())  

n = 0
while(h != 0):
    h = h >> 1
    n+=1

print((2**n) -1)

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