Problem:
 Score : 400 points    Problem Statement Caracal is fighting with a monster.  The health of the monster is H .  Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:   If the monster's health is 1 , it drops to 0 .  If the monster's health, X , is greater than 1 , that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor .   ( \lfloor r \rfloor denotes the greatest integer not exceeding r .)  Caracal wins when the healths of all existing monsters become 0 or below.  Find the minimum number of attacks Caracal needs to make before winning.      Constraints  1 \leq H \leq 10^{12}  All values in input are integers.         Input Input is given from Standard Input in the following format:  H       Output Find the minimum number of attacks Caracal needs to make before winning.        Sample Input 1 2      Sample Output 1 3  When Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1 .  Then, Caracal can attack each of these new monsters once and win with a total of three attacks.       Sample Input 2 4      Sample Output 2 7       Sample Input 3 1000000000000      Sample Output 3 1099511627775

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

if H == 1:
  print(1)
else:
  cnt = 1

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

    H = 2 ** (cnt-1)

  cnt = H
  two = H

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

  print(int(cnt+1))

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

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

Solution (Python):


import sys
input=sys.stdin.readline

h=int(input())
cnt1=1
cnt2=0

while h>1:
    h=h//2
    cnt1*=2
    cnt2 += cnt1//2

print(cnt1+cnt2)

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

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

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

Solution (Python):
H = int(input().rstrip())
ret = 0
if H == 1:
    ret = 1
elif H in [2, 3]:
    ret = 3
else:
    count = 0
    while H != 1:
        H = H // 2
        count += 1
    ret = 3
    for i in range(count-1):
        ret = 2*ret + 1
print(ret)

Solution (Python):

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

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

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

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

print(ans)

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

Solution (Python):
import math

h=int(input())
if h==1:
  print(1)
  exit(0)
count=0
for i in range(math.floor(math.log(h, 2))+1):
  p=int(math.pow(2, i))
  count+=p
print(count)

Solution (Python):

H = input()
H = int(H)

ii = 1
ans = 1

while True:
  if H <= 1:
    ans = ans + ii - 1
    break
  else:
    H = H//2
    ii = ii*2
    ans = ans*2
    

print(ans)

Solution (Python):
n = int(input())
flag = True
ans = 1
now = n
count = 1


for i in range(10000):
    if n > 2**i:
        pass
    elif n == 1:
        print(1)
        break
    elif n == 2**i:
        print(4*(2**(i)//2)-1)
        break
    else:
        print(4*(2**(i-1)//2)-1)
        break

Solution (Python):
import math

h=int(input())
if h==1:
  print(1)
  exit(0)
tmp=math.log(h, 2)
tmp2=math.floor(tmp)
if tmp-tmp2>0:
  h=h//2+1
count=0
for i in range(tmp2+1):
  p=int(math.pow(2, i))
  count+=p
  
print(count)

Solution (Python):

def f(h):
    return 2 * f(h // 2) + 1 if h else 0
print(f(int(input())))

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

r = int(math.pow(2,int(math.log(n, 2)) + 1) - 1)
print(r)

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

Solution (Python):
h=int(input())
cnt=0
tmp=[]
ans=1
while(h>1):
  h=h//2
  cnt=cnt+1
  tmp.append(cnt)
for i in tmp:
  ans=2**i
print(ans*2-1)

Solution (Python):
from bisect import bisect_right
 
n=int(input())
lst=[1]
lst2=[1]
for i in range(1,41):
  lst.append(2**i)
  lst2.append(lst2[i-1]+lst[i])
  
ind=bisect_right(lst,n)
print(lst2[ind-1])

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

if H==1:
    print(1)

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

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

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

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

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

Solution (Python):
h = int(input())
n = 1
while(h!=1):
    h=h//2
    n=n+1
total=0
for i in range(n):
    total+=2**i
print(total)

Solution (Python):
def main():
    H = int(input())
    n = 1
    ans = 0
    a = 1
    while H != 1:
        H = H // 2
        n += 1
    print(2 ** n - 1)
main()

Solution (Python):
"""
if a monster is not attacked, it doesn't do anything, so we can
deal with each living monster as a separate problem that takes
a certain number of moves to kill it and all of its offspring.
when x is not 1,
num(x) = 2*num(floor(x/2))+1
(because it took one move to kill it, and there will be two offspring)
and when x is 2 or 3,
num(x) = 3
so we can do some recursion, or memoization, or tabulation
"""

from math import floor


def get_num_attacks(H):
  if H>3:
    return 2*get_num_attacks(floor(H/2))+1
  if H==2 or H==3:
    return 3
  if H==1:
    return 1


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

Solution (Python):

H=int(input())
import math
keisuu=[]
i=39

while i>=1:
  if H >= 2**i:
    H -= 2**i
    keisuu.append(1)
  else:
    keisuu.append(0)
  i -=1
  
if H==1:
  keisuu.append(1)
else:
  keisuu.append(0)
  
while keisuu[0]==0:
  keisuu.pop(0)
  
keisuu.reverse()

a=len(keisuu)

if a>=2:
  ans=(2**a)-1
  print(ans)
else:
  print(1)

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

Solution (Python):

import sys

def solve(H: int):

    if H == 1:
        print("1")
        return

    i = 1
    m = 1

    while True:
        H = H // 2
        i *= 2
        if H == 1:
            i += i
            i -=1
            break
    print(i)

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

atk = 1

for i in range(100):
    h = h//2
    atk = atk * 2
    if h == 0:
        break


print(atk-1)

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

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

sum = 0
a = H
fin = 1

if H == 1:
  sum = sum + 1
else :
  while a>=1 :
    a = a/2
    sum = sum + 1
    
for n in range(sum):
  fin = fin *2
print(fin -1)

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

attack = 0
kai = 0

while h//2**kai>=1:
    attack += 2**kai
    kai += 1

print(attack)

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

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

c = c + 1

r = 1
re = 1
for _ in range(1,c):
    r *= 2

    re +=r
print(re)

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

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

def solve(H, n):
    if H == 1:
        return n
    else:
        return n + solve(H//2, n*2)

print(solve(H, 1))

Solution (Python):
import math

H = int(input())

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

print(2**count-1)

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

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

def sep_to_1(n):
    sep_mon=n
    count=0
    mons_num=1
    sum_sep_count=0
    while sep_mon!=1:
        count+=1

        sep_mon=sep_mon//2
        sum_sep_count+=mons_num
        mons_num=2*mons_num
        



    return sum_sep_count+mons_num

print(sep_to_1(N))

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

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

attack = 0
for i in range(step):
    attack += 2 ** i

print(attack)

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

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

i = 0
a = 0

while True:
    H = H // 2
    a += 2**i
    if(H <= 0):
        break
    i += 1

print(a)

Solution (Python):
hp = int(input())
nmons = 1
numatk = 0

while hp != 0:
    if hp == 1:
        numatk += nmons
        hp = 0
    else:
        hp /= 2
        hp = int(hp)
        numatk += nmons
        nmons *= 2

print(numatk)

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

double = 0
for i in range(h, 1, -1):
  if h == 1:
    break
  h = h // 2
  double += 1

total = 0
for i in range(double + 1):
  total += pow(2, i)
print(total)

Solution (Python):
H = int(input())
waru = H
cont = 0
while(1):
  if waru<=1:
    break
  waru = int(waru/2)
  cont = cont + 1
  
  
  
kaizyo = []

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

print(sum(kaizyo[:cont+1]))

Solution (Python):
import math
H = int(input())
cnt = 0
n = math.floor(math.log2(H))
ans = 0
for i in range(n+1):
    cnt += int(math.pow(2,i))
print(cnt)

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

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

Solution (Python):
s = input()  
n = 0
unchi = int(s)
ans = 0

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










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

print(ans+1)

Solution (Python):
h=int(input())
d=dict()
d[0]=0
d[1]=1
d[2]=3
d[3]=3
def solve(h):
    if h in d.keys():
        return d[h]
    d[h]=2*solve(h//2)+1
    return d[h]
print(solve(h))

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

Solution (Python):
def nextPow(x):
    xx = 1
    while xx * 2 <= x:
        xx *= 2
    return xx










import math

H = int(input())
result = 1







first = 1
if H == 1:
    print(1)
    exit(0)
elif H == 2:
    print(first + 1 + 1)
    exit(0)
elif H == 3:
    print(first + 1 + 1)
    exit(0)

result = 1
np = nextPow(H)
result += (np - 1) * 2

print(result)

Solution (Python):
H=[int(input())]
m=0
while len(H)!=0:
    for i in H:
        if i>1:
            H.append(int(i/2))
            H.remove(i)
            m=(m+1)*2
        else:
            H.remove(i)
            m+=1
print(m)

Solution (Python):
import sys

use_clipboard=True
bbn=1000000007
	


class dd:
	def __init__(self, a_h):
		self.h=a_h

		
def main():
	h=int(input())
	ret = 0
	ec=1
	while h >= 1:
		ret += ec
		ec *= 2
		h = h // 2 
	print(ret)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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())
count = 0
while h!=1:
  h = h//2
  count += 1
print(sum([2**i for i in range(count+1)]))

Solution (Python):
h = input()
h = int(h)
count = 0
attack = 0

if h > 1:
  while h >= 1:
    h = h / 2 
    count = count + 1
  for i in range(0, count):
    attack = attack + (2**i)
  print(attack)
else:
  print(1)

Solution (Python):
import numpy as np
import math 

h = int(input())


temp = math.floor(np.log2(h))
temp_sum = sum([2**i for i in range(0, temp)])

print(temp_sum+2**temp)

Solution (Python):
def main():
    H =int(input())
    bit_list = list(bin(H))
    del bit_list[:2]
    bit_in = [s.replace('0', '1') for s in bit_list]
    mojiretu = ' '
    for x in bit_in:
        mojiretu += x
    print(int(mojiretu, 2))
if __name__ == '__main__':
    main()

Solution (Python):

H = int(input())

ans = 1

tmp = H
bef = 1


while tmp > 1:
  tmp = tmp // 2
  
  if tmp >= 1:
    bef *= 2
    ans += bef

print(ans)

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

res = 0
i = 1
while h > 0:
  h = h//2
  res = res + i
  i *= 2
print(res)

Solution (Python):

def main():
    from sys import stdin, setrecursionlimit
    
    
    n = int(stdin.readline()[:-1])   
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    import math
    cnt = 0
    while n > 0:
        n = math.floor(n/2)
        cnt += 1
    print(2**(cnt)-1)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = input()
n = int(n)
count = 0
attack = 0

if n > 1:
  while n >= 1:
    n = n / 2 
    count = count + 1
  for i in range(0, count):
    attack = attack + (2**i)
  print(attack)
else:
  print("1")

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

Solution (Python):
H=int(input())
def cut(a):
	if a==1:
		return 1
	elif a%2==1:
		return 2*cut((a-1)//2)+1
	elif a%2==0:
		return 2*cut(a//2)+1
print(cut(H))

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

Solution (Python):
import numpy as np
import math

H = input()
H_bar=int(H)
counter=0
bunki=0

while H_bar!=1:
 H_bar=math.floor(H_bar/2)
 bunki=bunki+2**counter
 counter=counter+1
  
Sum=bunki+2**counter
print(Sum)

Solution (Python):
a = int(input())
attack_num = 0
num_list = []
count = 1

def attack(hp):
  global attack_num,num_list,count
  
  attack_num = attack_num + count
  count = count *2
  if hp <= 1:
    num_list.append(attack_num)
  elif hp % 2 == 0:
    attack(hp/2)
  elif hp % 2 == 1:
    attack((hp-1)/2)
    
    
attack(a)
print(num_list[-1])

Solution (Python):
import math

H = int(input())
ans = int(math.log(H, 2)) + 1
a = ans - 1
r = 0


for _ in range(ans - 1):
    ans += a * (2 ** r)
    r += 1
    a -= 1

print(ans)

Solution (Python):
import math
h = int(input())
 
s=0 
x=0
b = int(math.log(h, 2) + 1)
for i in range(b):
  if h is not 0:
    h = h/2
    s+=2**i
  else:
    continue
print(s)

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

Solution (Python):
import math

n=int(input())
n2=int(math.log(n,2))

print(2*(2**n2)-1)

Solution (Python):
import numpy as np

N = int(input())
N = bin(N)
x = len(str(N)) - 2

print(2 ** x - 1)

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

Solution (Python):
import math

H = int(input())
counter = 1

if H != 1:
    while True:
        H = math.floor(H / 2)
        if H > 1:
            counter += 1
        elif H == 1:
            break
    print(2**(counter + 1 ) - 1)
else:
    print(1)

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

n = 0

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

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

print(ans)

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

phase = 1
cnt = 1
while True:
    if H == 1:
        break
    H = math.floor(H/2)
    cnt += 2 ** phase
    phase += 1
print(cnt)

Solution (Python):

import sys


def solve(H: int):
    count = 0
    i = 0
    while H >= 1:
        H = H // 2
        count = count + 2 ** i
        i += 1
    print(count)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  
    solve(H)


if __name__ == "__main__":
    main()

Solution (Python):
num = int(input())
num2 = bin(num)
keta = len(num2)-2
if num == 1:
  print(1)
else:
  print(2 ** keta -1)

Solution (Python):
import math
H = int(input())
i = 1
if H == 1:
    print(1)
else:
    while H > 1:
        i = i + 1
        H = math.floor(H / 2)
    print(2 ** i - 1)

Solution (Python):
import math
H = int(input())
height = 1
div = H
while div > 1:
  div = math.floor(div / 2)
  height += 1
count = 2 ** height - 1

print(count)

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

sn = (n/2)* (4+(n-1)*2)
sn+=1

"""
r = 2
sn = ( 2*(r**n -1) )/(r-1)
  
print(int(sn+1))

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

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

print(2**count - 1)

Solution (Python):
def a(H):
    global ans
    global dic
    if H // 2 in dic:
        add = 2 * ans + 1
        ans = add
        dic[H] = add
    else:
        a(H//2)
        a(H//2)

H = int(input())
dic = {}
dic[1] = 1
ans = 1
if H != 1:
    a(H)
print(ans)

Solution (Python):
h=int(input())
c=0
if h==1:
    print("1")
else:
    while h!=1:
        h=h//2
        c=c+1
    k=pow(2,c+1)-1;
    print(k)

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

Solution (Python):
import math

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

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

Solution (Python):


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

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

n = int(np.log2(H))
ans = 2**(n+1)-1
print(ans)

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

Solution (Python):


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

H = int(input())
summ = aaa(H, 0, 0)

Solution (Python):
import math
H = int(input())
count = 0
enemy = 1
enemyH = H
while enemy > 0:
  if enemyH == 1:
    count += enemy
    enemy =0
  else :
    X = (enemyH/2)
    x = math.floor(X)
    enemyH =x
    count += enemy
    enemy =enemy*2
print(count)

Solution (Python):
monster_num = int(input())
times = 0
while(monster_num >= 1):
  monster_num = int(monster_num / 2)
  times += 1
ans_times = 0
for n in range(times):
  ans_times += 2 ** n
print(ans_times)

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

Solution (Python):
A = int(input())
ans_list = []
i = A
while i != 1:
    i = i//2
    ans_list.append(i)
B = len(ans_list)
a = 3
for i in range(1,B):
    a = a * 2 + 1
if A == 1:
    print(1)
else:
    print(a)

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

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

flag = True
n = 1
depth_num = 2

while flag:
    if 2 ** n - 1  < h:
        n += 1
    else:
        flag = False
        depth_num = n

result_num = 2 ** depth_num - 1
print(result_num)

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

count = 0 
n = 0

while h > 1:
    h = int(h/2)
    n += 1
    count += pow(2, n-1)

count += pow(2, n)
print(count)

Solution (Python):
import math

log = int(math.log2(int(input())))

num = 0
for i in range(log + 1):
    num = num + (2 ** i)

print(num)

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

i = 0
A = 0

while H >= 2**i:
  i += 1
  
for j in range(i):
  A += 2**j
print(A)

Solution (Python):
import math

h=int(input())

ans = 1
teki = 1

while (h!=1):
    h = math.floor(h/2)
    teki *= 2
    ans += teki

print(ans)

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

def attack(h):
    global count
    count += 1
    if h ==1:
        return 0
    if h > 1:
        attack(h // 2)

attack(H)
if H == 1:
    print(1)
else:
    
    print(2 ** (count) - 1)

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

for i in range(10**12):
    if 2**i > h:
        check = i-1
        break
print(2*(2**check)-1)

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

Solution (Python):
n= int(input())
print(2**(len(bin(n))-2)-1)

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

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

print(i + 1)

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

num = 0
while(1):
    num += 1
    h = h // 2
    if h < 1:
        break

print(2 ** num - 1)

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


n = x = 0
b = True
while b:
  if h != 1:
    h = h // 2
    n += 1
  else:
    b = False

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

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

Solution (Python):
h = int(input())
x = "1"*(len(bin(h))-2)
print(int(x,2))

Solution (Python):
count = 1

def number(h,count):
    if h<= 1:
        return count
    else:
        return number(h//2,count+1)
h = int(input())

key = number(h//2,count)
ans = 0
if h == 1:
    print(1)
else:
    for i in range(1,key+1):
        ans += 2**i
    print(ans+1)

Solution (Python):
h = int(input())
mem = [0] * 1000
cnt = 0

def atk(k):
    if k == 1:
        return 1
    else:
        j = int(k // 2)
        l = 0
        while k / ( 2 ** l) >1:
            l += 1

        if mem[l] == 0:
            mem[l] = atk(j) * 2 + 1
            return mem[l]
        else:        
            return mem[l]
if h > 1:
    atk(h)
    mem.sort(reverse = True)
    print(mem[0])
else:
    print(1)

Solution (Python):


H=int(input())



COUNT = 0
for i in range(10000000000):
    temp = pow(2,i)
    if temp == H:
        COUNT = i
        break
    elif temp > H:
        COUNT = i-1
        break



SUM = 0
for j in range(COUNT+1):
    SUM += pow(2,j)

print(SUM)

Solution (Python):
h = int(input())
for i in range(1, 41):
  x = 2 ** i -1
  if h <= x:
    print(x)
    break

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

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())
if H == 1:
  print(1)
  exit()
n, cnt = 1, 1

while cnt < H:
  n *= 2
  cnt += n
  
print(cnt)

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

b = len(format(H, 'b'))

sum = 0
for i in range(0, b):
    sum += 2 ** i

print(sum)

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

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

k=0
p=0
while h!=1:
    k+=2**p
    h=h//2
    p+=1
print(k+2**p)

Solution (Python):
H = int(input())
s2 = 0
if H == 1:
    print(1)
else:
    while H >= 2**s2:
        s2 +=1
    s2 -= 1
    s3 = 1
    cnt = 3
    while s3 < s2:
        cnt = 1 + cnt *2
        s3 += 1
    print(cnt)

Solution (Python):
m=int(input())
i = 0
while m > 0:
  m = m//2
  i += 1
li=list(range(i))
la=[2**x for x in li]
print(sum(la))

Solution (Python):
import math

H = int(input())
i = 1
while ( i * 2 <= H):
    i *= 2

k = int(math.log(i, 2))

def f(n):
    return 2 ** n

def sigma(func, frm, to):
    result = 0;
    for i in range(frm, to+1):
        result += func(i) 
    print(result)
    
sigma(f, 0, k)

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

def number_attack(n):
    if n == 1:
        return 1
    
    answer = 1 + 2 * number_attack(math.floor(n/2)) 
    return answer
  
answer = number_attack(N)

print(answer)

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

memo_count = {}
def searchCount(h):
    if h==1: 
        return 1
    elif h in memo_count:
        return memo_count[h]
    else:
        h_half = int(h / 2)
        memo_count[h] = 1 + 2*searchCount(h_half)
        return memo_count[h]

print(searchCount(H))

Solution (Python):
H=int(input())
temp=H
answer=0

for i in range(100):
    if  abs(H-2**i)<temp:
        temp=abs(H-2**i)
        answer=i
        
        
        
    else:
        fuge=0
        
        
        
if H<(2**answer):
    
    print(2**answer-1)
else:
    
    print(2**(answer+1)-1)

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

cnt = 0
ans = 0

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

print(ans)

Solution (Python):
h=int(input())
if h==1:
    print(1)
else:
    count=0
    ans=1
    if h%2==1:
        h-=1
    while h>1:
        h//=2
        count+=1
    for i in range(count):
        ans*=2
    print(ans*2 - 1)

Solution (Python):
import math

H = int(input())
i = 1
j = [1]

while H > 1:
    H = math.floor(H/2)
    i = i * 2
    j.append(i)

print(sum(j))

Solution (Python):
from functools import lru_cache
h = int(input())
count = 0

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

@lru_cache(maxsize=100000)
def f(n):
    if n < 1:
        return 1
    else:
        return f(n - 1)*2 + 1

print(f(count))

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

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

Solution (Python):
import math
LogT={1:1}
def  div2(X):
    if X in LogT:
        return LogT[X]
    else:
        v = 1+div2(math.floor(X/2))*2
        LogT[X]=v
        return v

if __name__=='__main__':
    H=int(input())
    print (div2(H))

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

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

count = 0
while count >= 0 :
  count += 1
  if h != 1 :
    h = h // 2
    count = count*2
  else :
    print(count)
    break

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

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

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

N=len(bin(H))-2

count=0
if sum(list(map(int, bin(16)[3:])))==0:
  for i in range(N):
    count+=2**i
else:
  N=N+1
  for i in range(N):
    count+=2**i
    
print(count)

Solution (Python):
import math

h = int(input())
count = 1

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

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

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





























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

print(2**i - 1)

Solution (Python):
import math
h = int(input())
hp = h
c = 0
ans = 0

while hp > 1:
    hp = math.floor(hp/2)
    c += 1
for i in range(0,c+1):
    ans += 2 ** i
print(ans)

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

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

print(result)

Solution (Python):
N = int(input())
L = [1]
count = 1
while N > 1:
    N = int(N/2)
    count *=2
    L.append(count)
print(sum(L))

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

count = 0
damage = 1
sum_damage = 1

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

for i in range(1, count):
    damage = damage * 2
    sum_damage += damage

print(int(sum_damage))

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

n=0
for i in range(10**12):
  if h<2**i:
    n=i-1
    break
ans=1
for i in range(1,n+1):
  ans+=2**i
print(ans)

Solution (Python):
H = int(input())
bin_H = format(H,'b')
n = int(len(bin_H))

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

Solution (Python):
h = int(input())
for i in range(1000):
    if h == 0:
        a = 2 ** (i)-  1
        print(a)
        break
    h = h // 2

Solution (Python):
import numpy as np
import math


N = int(input())

res = 1

end = N // 2



for i in range(math.floor(np.log2(N))):
    res = res * 2 + 1

print(res)

Solution (Python):
import sys
import math
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

h = int(read())

q = [h]
now = h

while now > 1:
  now = math.floor(now / 2)
  q.append(now)

total = 1
for i in range(1, len(q)):
  total += 2 ** i

print(total)

Solution (Python):
import math
H = int(input())
if H == 1:
    print(H)
else:
    print(int(math.pow(2,int(math.log2(H))+1)-1))

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

print(count)

Solution (Python):


def n_jou(n):
    cnt=0
    while n>1:
        n=int(n/2)
        cnt+=1
    return cnt

n=int(input())
k=n_jou(n)
ans=0
for i in range(k+1):
    ans+=2**i
print(ans)

Solution (Python):
def resolve():
    h = int(input())
    count=0
    while True:
        if h ==1:
            break
        h = int(h/2)
        count +=1
    
    ans = 0
    for i in range(count+1):
        ans+=2**i
    print(ans)

if __name__ == "__main__":
    resolve()

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())
ans = 0

while H > 1:
    if H%2 == 0:
        H = H/2
        ans += 1
    else:
        H = (H-1)/2
        ans += 1
N = 2**ans
def fight(k):
    if k == 1:
        return 1
    else:
        return 2*fight(k/2)+1
    
        
print(fight(N))

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

import math

ans = 1
p_ans = 1

logh = int(math.log2(h))
for i in range(logh):
  ans += p_ans * 2
  p_ans = p_ans * 2

print(ans)

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

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

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

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

print(dfs(h))

Solution (Python):
import math
a = list(map(int,input().split()))
b = int(math.log(a[0], 2))
c = 2 ** (b+1) -1
print(c)

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

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

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

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

counter = 0
sub = 1

while H > 0:
    H = int(H/2)
    counter += sub
    sub *= 2

print(counter)

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

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

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

Solution (Python):
import sys
import numpy as np


h = int(input())

bin_str = format(h, 'b')

cnt = 2 ** (len(bin_str)) - 1

print(cnt)

Solution (Python):
import math

h = int(input())

dp = dict()
dp[1] = 1
def rec(parent):
    child = math.floor(parent / 2)
    if parent == 1:
        return 1
    elif child in dp:
        return 2 * dp[child] + 1
    else:
        return 2 * rec(child) + 1

print(rec(h))

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

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