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 numpy as np
H = int(input())
count = 0
ans = 0

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

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

import math as m
a = int(m.log2(h))

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

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

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

Solution (Python):

H = int(input())

def get_attack_num(n):
    if n == 1:
        return 1
    elif n == 2 or n == 3:
        return 3
    return get_attack_num(n//2) * 2 + 1

print(get_attack_num(H))

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

while H != 1:
    ans += 2 ** num
    num += 1 
    H = H // 2

ans += 2 ** num
print(ans)

Solution (Python):
from math import log2


def closest_power_of_2(x: int):
    return int(log2(x))


def attacks(x: int):
    return int(2 ** (log2(2 ** closest_power_of_2(x)) + 1) - 1)


if __name__ == '__main__':
    h = int(input())

    print(attacks(h))

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

m =1
cnt=0
if h <=1:
    print(1)

elif h <=3:
    print(3)
else:
    while h >3:
        h = h //2
        cnt+=m
        m = m*2


    cnt=cnt+m*3
    print(cnt)

Solution (Python):


import numpy as np
from sys import stdin


def get_result(data):
    cnt = 0
    quotient = data
    while quotient > 1:
        quotient = quotient // 2
        cnt += 1
    return 2**(cnt+1) - 1

if __name__ == '__main__':
    data = int(stdin.readline())
    result = get_result(data)
    print(result)

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

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

for i in range(cnt): 
    if i == 0:
        result = 1
    else:
        result = result + (2 ** i)

print(result)

Solution (Python):
h=int(input())
ans = 0
temp = 1
for i in range(10000):
  if h//2 == 0:
    ans += temp
    break
  else:
    h = h//2
    ans += temp
    temp *= 2
print(ans)

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

flag = 0
dp = []
dp.append([H,1])

for i in range(1,H):
    tmp0 = dp[i-1][0]//2
    tmp1 = dp[i-1][1]*2
    dp.append([tmp0,tmp1])
    if dp[i][0]==1:
        break

l = len(dp)
p = [dp[i][1] for i in range(l)]
ans = sum(p)
print(ans)

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

Solution (Python):
N = int(input())
i = 0
check = 1

while N >= check:
    i += 1
    check = 2**i
print(2**i-1)

Solution (Python):
import sys
import math

sys.setrecursionlimit(1000000000)

def dfs(hit):
    if (hit <= 1):
        return 1
    else:
        return 1 + dfs(math.floor(hit / 2)) * 2

H, = list(map(int, input().split()))
print(dfs(H))

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

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

h = inp 
cnt = 0
while (h != 1):
    cnt += 1
    h = h / 2
cnt += 1
ans = (1 << (cnt)) -1
print ans

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

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

for i in range(1,h):
    ans += 2 ** i
    h = h // 2
    if h == 1:
        break

print(ans)

Solution (Python):
import math

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

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

Solution (Python):
import math

H=int(input())
C=0
while H!=0:
  H=math.floor(H/2)
  C+=1

print(2**C-1)

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

    i = 0

    while(h >= 1):
        h //= 2
        i += 1

    print(2**i-1)

if __name__ == '__main__':
    main()

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

print(ans)

Solution (Python):
import sys
import fractions
input = sys.stdin.readline
H = int(input())
ans = 0
for i in range(100):
    if H == 0:
        print(ans)
        break
    H //= 2
    ans += 2**i

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


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

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

Solution (Python):
H=bin(int(input()))[2:]
L=len(H)
a_list=[2**i for i in range(L)]
print(sum(a_list))

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

L = int(np.log2(H))
K = ceil(np.log2(H))
if K == L:
    count = K
else:
    count = K - 1
L = 2 ** (count + 1) - 1

print(L)

Solution (Python):
n = int(input())
co = 0
for i in range(10**12):
  n = n/2
  co += 1
  if n < 1:
    break

ans = []
a = 1

for i in range(co):
  ans.append(a)
  a *= 2

print(sum(ans))

Solution (Python):
H = int(input())
memo = {1: 1}
def dfs(h):
  global memo
  memo[2] = 3
  if h in memo:
    return memo[h]
  memo[h] = dfs(h // 2) + dfs(h // 2) + 1
  return memo[h]
print(dfs(H))

Solution (Python):
def run():
  H = int(input())
  n = 0
  while H > 0:
    n += 1
    H //= 2
  print(2**n-1)
      
  
if __name__ == '__main__':
  run()

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

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

Solution (Python):
import math
h=int(input())
ans=0
n=math.ceil(math.sqrt(h))+1
for i in range(n):
    if h>=2**i:
        ans+=2**i
    else:
        break
print(ans)

Solution (Python):
n = int(input())
for i in range(0, 10**9):
  if(2**i <= n and n < 2**(i+1)):
    print(2**(i+1) - 1)
    exit()

Solution (Python):
def  caracal(H):
    k = 0
    n_sum = 0
    while H >n_sum :
        n_sum += 2**k    
        
        k +=1
    
    return n_sum


H = input()
H = int(H)

print(caracal(H))

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

count=0
plusnum=1

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

print(plusnum+count)

Solution (Python):
H = int(input())
answer = 1
n = 1
if H == 1:
    print(1)
    exit()
while True:
    answer += 2**n
    if 2**n <= H and H < 2**(n+1):
        break
    n += 1

print(answer)

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

Solution (Python):
d = {}

def f(h):
    if h == 1:
        return 1
    if h in d:
        return d[h]
    n = 1 + f(h//2) * 2
    d[h] = n
    return n
 

h = int(input())

print(f(h))

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

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

print(ans)

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

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

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

Solution (Python):

 
import math
import itertools
import sys
import copy
 







H = int(input())

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


sum = 1
y = 1
for i in range(cnt) :
  sum += y*2
  y *= 2
  
print (sum)

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

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

attack = 1
while h > 0 :
    h = h // 2
    attack *= 2

print(attack - 1)

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

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

Solution (Python):
import queue
import copy
import math
from collections import deque

h = int(input())

if h == 0:
    print(0)
    exit(0)

if h == 1:
    print(1)
    exit(0)

depth = math.log2(h)


waru = 0
target = h
while True:
    d, m = divmod(target, 2)
    target = d
    waru += 1
    if target == 1:
        break
    else:
        continue

d, m = divmod(h, 2)

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

print(ans)

Solution (Python):




def solve(H):
    ans_attack = 0
    hp = H
    enemy = 1

    while hp > 1:
        hp = hp // 2
        ans_attack = ans_attack + enemy
        enemy = enemy * 2

    return ans_attack + enemy


H = int(input())

print(solve(H))

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

n = 0
while (h != 1):
    h = h // 2
    n += 1

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

Solution (Python):
import math
count = 1
def kaisu(H,Y):
    global count
    if H == 1:
        return True
    else :
        if kaisu(math.floor(H/2),Y * 2):
            count += Y * 2
            return True

H = int(input())
kaisu(H,1)
print(count)

Solution (Python):
t=int(input())
s=0
def kara(t,s):
    if t==1:
        s=s+1
        return 1
    else:
        t=int(t/2)
        s=s+1
    return kara(t,s)*2+1

print(kara(t,s))

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

import math

class Tree:
    def __init__(self, hp):
        self.hp = hp
        self.sons = []

    def split(self):
        return Tree(math.floor(self.hp/2)),Tree(math.floor(self.hp/2))
    

H = int(input())

num = 0
x = H
while x>1:
    x = math.floor(x / 2)
    num += 1



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


print(ans)

Solution (Python):
H = int(input())
H_list = [H]
ans = 0
while H > 0:
  H = int(H / 2)
  H_list.append(H)
for i in range(1, len(H_list) - 1):
  ans += 2 ** i
print(ans + 1)

Solution (Python):
import sys
import math
read = sys.stdin.buffer.read 
readline = sys.stdin.buffer.readline 
readlines = sys.stdin.buffer.readlines 
H = int(read())
if H == 1:
  print(1)
  exit()

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

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

Solution (Python):
import math

def main(H):
    res = 0
    count = 0
    val = H
    while 1 < val:
        val = math.floor(val/2)
        count += 1
    for i in range(count+1):
        res += 2**i
    print(res)

H = int(input())
main(H)

Solution (Python):
import math
n = int(input())
n_log = math.log(n,2)
n_log_2 = math.floor(n_log)
print(2**(n_log_2+1)-1)

Solution (Python):
H = int(input())
cnt=0
sumA=0
while H>1:
    cnt +=1
    H = H // 2
    if H ==1:
        break
for i in range(cnt+1):
    sumA += 2**i
print(sumA)

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

    print(ans)

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

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

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

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

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

n = 1

def check(n, k):
  
  if((k//2) >= 1):
    n += 1
    k = k // 2
    check(n, k)
  else:
    print(2**n - 1)
    
check(n, h)

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

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

print(temp)

Solution (Python):


H = int(input().strip())
attachs = {}

def needed_attach(value):
  
  if value == 1:
    return 1
  else:
    if value in attachs:
      x = attachs[value]
    else:
      x = needed_attach(value // 2) * 2 + 1
      attachs[value] = x
    return x

print(needed_attach(H))

Solution (Python):
import math

h = int(input())

c = math.floor(math.log2(h))+1

print(2**c - 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())

import math

i = 0
sum = 0
while H >= 1:
	H = math.floor(H/2)
	sum += 2**i
	i += 1
print(sum)

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

if H==1:
    print(1)
    
else:
    while H!=0:
        H=H//2
        at+=1
    ans=1
    preans=1
    for i in range(2,at+1):
        ans+=preans*2
        preans=preans*2
    print(ans)

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

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

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

H = int(input())
"""2
def attack(x,n):
  if x == 1:
    return 2**n
  else:
    return attack(x//2,n+1) + 2**n

print(attack(H,0))

exit()
"""

attack_count = 0
attack_time = 0

while(H > 0):
  H = H // 2
  attack_count += 2**attack_time
  attack_time+=1

print(attack_count)

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

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



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

Solution (Python):
import math

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

    node = math.floor(math.log2(n)) + 1

    print(2 ** node - 1)




if __name__ == "__main__":
    main()

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

ans = 0
rate = 1

while H != 0:    
    ans += rate
    rate = rate * 2
    H = H // 2

print(ans)

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

print(steps(a))

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

n = 0
while True:
    if 2 ** n <= H < 2 ** (n+1):
        break
    n += 1
if n == 0:
    ans = 1
else:
    ans = 1
    for i in range(1, n+1):
        ans += 2**i

print(ans)

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

A = []
count = 0

while(H>0):
  count += 1
  A.append(H)
  H = H//2

ans = 0
temp = 1
for i in range(count):
  if(i==0):
    ans += temp
  else:
    temp = temp*2
    ans += temp
    
print(ans)

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

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

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

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

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

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

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

result = 0
attack = 1
loop = 1
while H > 1:
    H = H // 2
    loop += 1

arr = [2**i for i in range(loop)]
print(sum(arr))

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

Solution (Python):

import math
h = int(input())

def c(i):
    if i == 1: return 1
    elif i == 0: return 0
    else: return 1 + 2*c(i//2)
print(c(h))

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

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

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

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

Solution (Python):
from sys import stdin

def attack(h):
    if h <= 1:
        return 1
    f = {}
    n = 1
    while (h // 2 > 1):
        h = h // 2
        n += 1
    for i in range(n):
        f[i] = 0
    f[0] = 1
    for i in range(1, n + 1):
        f[i] = f[i-1] * 2 + 1
    return f[n]

if __name__ == '__main__':
    h = int(stdin.readline().rstrip())
    print(attack(h))

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


if __name__ == '__main__':
    resolve()

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

Solution (Python):

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

    bin_H = str(format(H, 'b'))
    length = len(bin_H)

    ans = str(1) * length
    print(int(ans, 2))


if __name__ == '__main__':
    main()

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

cnt = 1
res = 0

while h > 0:
    h = h//2
    res += cnt
    cnt *= 2

print(res)

Solution (Python):
import math

ans = 0
for i in range(1, math.floor(math.log2(int(input()))) + 1):
    ans += 2 ** i
print(ans + 1)

Solution (Python):

H_new = {int(input()):1} 
ans = 0

while True:
    X = H_new
    H_new = {}
    for k, v in X.items():
        if k == 1:
            ans += v
        else:
            ans += v
            h = int(k//2)
            if h in H_new:
                H_new[h] = H_new[h]+v*2
            else:
                H_new[h] = v*2
    if len(H_new) == 0:
        break
    
print(ans)

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

x = H
y = 0
r = 0
while True:
    if x == 1:
        break
    x = x // 2
    y += 1
    r += 2**y

print(r + 1)

Solution (Python):
H = int(input())
res = 0
for i in range(40):
    if 2**i <= H < 2**(i+1):
        for j in range(0, i+1):
            res = res + 2**j
print(res)

Solution (Python):
h = int(input())
a = 1
w = 'no'
while w == 'no':
    if h//2**a == 0:
        w = 'yes'
    else:a += 1
print(2**a-1)

Solution (Python):

H = int(input())


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


print(2**i-1)

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

Solution (Python):
import math
import time

if __name__ == '__main__':
    a = int(input())
    count = 0
    while(a != 1):
        count += 1
        a = math.floor(a / 2)
    sum_d = 0
    d = 1
    for i in range(count):
        sum_d += 2 ** d
        d += 1
    print(sum_d + 1)

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

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

print(func(H))

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

H = int(input())

depth = 0
ans = 0

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

ans += 1 * (2 ** depth)

print(ans)

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

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

stage = 1
kai = 1

while stage*2 <= i:
    stage = stage*2
    kai += 1

stage = stage // 2
kai -= 1

r = 0
while kai > 0:
    r += 2 ** kai
    kai -= 1

print(r + 1)

Solution (Python):


import sys

H = int(input())

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

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

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

counter = 1
result = 0

while N!=1:
    N = N//2
    result += counter
    counter *= 2
result += counter
print(result)

Solution (Python):
import math

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

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

print(2**cnt*2-1)

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

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

Solution (Python):
import math

h = int(input().rstrip())

a = int(math.log2(h))

sum = 0

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

print(sum)

Solution (Python):
print(2 ** len('{0:b}'.format(int(input()))) - 1)

Solution (Python):
H=int(input())
cnt,ans,tmp=1,1,1
while tmp<=H:
    if tmp*2 <= H:
        ans+=2**cnt
        cnt+=1
        tmp=tmp*2
    else:
        break
print(ans)

Solution (Python):
h = int(input())
ans = 0
for i in range(41):
    if 2**i <= h < 2**(i+1):
        for k in range(i+1):
            ans += 2**k
print(ans)

Solution (Python):

import math
H=int(input())
ans=0
k=0
while H >0:
    H=H//2
    k+=1
    ans+=math.pow(2,k-1)
print(int(ans))

Solution (Python):
import math

h = int(input())

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

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

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())
hh = h
kaisuu = 0
while h>1:
    h //= 2
    kaisuu += 1

if hh==1:
    print(1)
else:
    ans = 1
    for i in range(1, kaisuu+1):
        ans += 2**i
    print(ans)

Solution (Python):
import math

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

Solution (Python):
import sys
import math

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

atk=0
mst=1

while(1):
    if h==1:
        atk+=mst
        break
    else:
        h=(math.floor(h/2))
        atk+=mst
        mst=mst*2

print(atk)

Solution (Python):
import math
def hanbun(H):
  ans=(H/2)
  return math.floor(ans)
H=int(input())
count=0
temp=H
while temp!=0:
  temp=hanbun(temp)
  count=count+1
print (2**count-1)

Solution (Python):
import math
s = list(map(int, input().split()))
l=int(math.log2(s[0]))
print(int(2**(l+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):
import math
h = int(input())
count = 0
while h != 1:
    h = math.floor(h / 2)
    count += 1
ans = [2 ** i for i in range(count + 1)]
print(sum(ans))

Solution (Python):
import math
import sys

H = int(input())

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

times = 0
while H > 1:
    H = math.floor(H/2)
    times += 1

ans = 1
tmp = 1
for i in range(0,times):
    tmp = tmp*2
    ans = ans + tmp
    
print(ans)

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

cnt = 1
hit_point = 1
base = 1
while H > hit_point:
    base *= 2
    cnt += base
    hit_point *= 2
    if hit_point * 2 > H:
        break

print(cnt)

Solution (Python):

import math

H = int(input().split()[0])
c = 0
now_h = H
i = 0
while now_h >= 1:
    now_h = now_h // 2
    if i == 0:
        c += 1
    else:
        c += 2 ** i
    i += 1

ans = c
print(ans)

Solution (Python):


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

Solution (Python):

def nextPowerOf2(n): 
	count = 0; 

	
	
	
	if (n and not(n & (n - 1))): 
		return n 
	
	while( n != 0): 
		n >>= 1
		count += 1
	
	return 1 << count; 





def ispowerof2(num): 

	if((num & (num - 1)) == 0): 
		return 1
	return 0




n=int(input())
if(n==1):
	print(1)
else:
	if(ispowerof2(n)):
		print(2*n-1)
	else:
		k=nextPowerOf2(n)
		k=k//2
		print(2*k-1)

Solution (Python):


H = int(input())

pw = 2

if H == 2 or H ==3:
    print(3)
else:
    while H >= pw:
        pw = pw * 2
    print(pw - 1)

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

Solution (Python):
N=int(input())
kotae=0
count=0
kari=N
while kari>1:
    count=count+1
    kari=kari//2

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

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

binary = len(bin(h))-2

print(2**binary-1)

Solution (Python):
hp = int(input())
import math
x = int(math.log(hp,2))

res = 0
for i in range(x + 1):
    res += 2 ** i
    
print(res)

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

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

power_2 = 1
i = 0
while power_2 <= H:
    power_2 = power_2 * 2
    i += 1

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

print(num)

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

Solution (Python):
import math

h = int(input())

hn = int(math.log2(h))

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

print(r)

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


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


print(div2(H))

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

count = 0
count = int(math.log2(H))

total = 0
total = int((1 - (2**(count + 1)))/(1 - 2))
print(total)

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

sum=0
num=1
h=H

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

print(sum)

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

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

time = 0
now = H
pow2list = [2**i for i in range(50)]

import math
a = math.log(now, 2)
print(sum(pow2list[0:math.floor(a+1)]))

Solution (Python):
import math
H = int(input())
a = math.log(H, 2)
ans = 0

b = int(a)
for i in range(b + 1):
    ans += 2 ** i
print(ans)

Solution (Python):
import math

h = int(input())

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

attack = 0

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

print(attack)

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

def func(a):
    res=0
    for i in range(a):
        res+=int('1'+'0'*i,2)
    return res

bin_H=format(H,'b')
len_bin_H=len(bin_H)
s_bin='1'+'0'*(len_bin_H-1)

ans=func(len_bin_H)
print(ans)

Solution (Python):
r=int(input())
p=0
for i in range(100):

    if 2**p<=r and r<2**(p+1):
        break
    p+=1
        
print(2**(p+1)-1)

Solution (Python):
import math
H = int(input()) 
L = []
X = H
i = 0
while X != 1:
    X = math.floor(X/2)
    i += 1
print(int((1-2**(i+1))/(1-2)))

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

def find_pow(x):
    if x==1:
        return 0
    else:
        res = 0
        t = 1
        while(t <= x):
            t *= 2
            res +=1
    return res-1

p = find_pow(H)
res = 0
for i in range(p+1):
    res +=2**i
print(res)

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations

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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



H = intinput()

n = floor(log2(H))

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



print(ans)

Solution (Python):
import math

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

Solution (Python):
import math

H = int(input())


def main():
    split_cnt = int(math.log2(H))

    atk_cnt = 0

    for i in range(split_cnt + 1):
        atk_cnt += 2 ** i
    return atk_cnt


ans = main()

print(ans)

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

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

ans = 1
cur = 1
for _ in range(1, cnt):
  cur *= 2
  ans += cur
  
print(ans)

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

count = 0
while not H == 1:
    H //= 2
    count += 1

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

Solution (Python):
import math
n=int(input())
j=math.floor(math.log(n,2))
a=0
for i in range(0,j+1):
    a=a+pow(2,i)
print(a)

Solution (Python):
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

h = ni()

ans = 0
a = h // 2
c = 0
while h != 0:
    ans += 2 ** c
    h //= 2
    if c == 0:
        c += 1
    else:
        c += 1

print(ans)

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

Solution (Python):
import math

def lb(x):
    return math.log(x)/math.log(2)


H=int(input())
idx=math.floor(lb(H))
tb= []
tb.append(1)
i=0
while i<50:
    i+=1
    tb.append(1+2*tb[-1])

print(tb[idx])

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

for i in range(41):

    if H < 2**i:
        kaisu = 2**(i)-1
        break
    elif H == 2**i:
        kaisu = 2**(i+1)-1
        break
        
print(kaisu)

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

count = 1

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

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

count = 0

while health != 0:
    health = health // 2
    count += 1

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

Solution (Python):
h = int(input())
cnt = 0
for _ in range(h):
    h //= 2
    cnt += 1
    if h == 0:
        break
print(2**cnt -1)

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

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

print(int(str('1')*(n+1),2))

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

ans=0
n=1
while(H!=1):
    ans+=n
    H = int(H/2)
    n=n*2
    
    
    
print(ans+n)

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

    for i in range(50):
        if h < 2**i:
            print(2**i - 1)
            break


if __name__ == '__main__':
    main()

Solution (Python):
a=int(input())
t=1
j=0
p=1
while a!=1:
  if a%2==0:
    a/=2
    t+=1
    continue
  else:
    a=(a-1)/2
    t+=1
for i in range(t):
  j+=p
  p*=2
print(j)

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

import math
n = int(math.log(H, 2))

ans = 0
for i in range(n + 1):
    ans += pow(2, i)
    
print(ans)

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

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

print(2 ** count - 1)

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

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

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

print(total)

Solution (Python):
import math

H = int(input())

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

Solution (Python):
h = int(input())
cnt = 0
lists = []
while h != 1:
    cnt += 1
    h = h//2
    lists.append(2**cnt)
print(sum(lists)+1)

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

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

H2 = H

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



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

print(ans)

Solution (Python):
import math


n=int(input())
tmp=bin(n)[2:]
ans=1
for _ in range(len(tmp)-1):
    ans=ans*2+1
print(ans)

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

count=0

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

print(2**i-1)

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

cnt = 0
ls = []

while H >= 2:
    cnt += 1
    ls.append(int(2 ** cnt))
    H //= 2


print(sum(ls) + 1)

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

Solution (Python):
import math
a = int(input())
b = math.ceil(math.log2(a))
print(2**(b+1) - 1 if a == 2** b else 2**b - 1)

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

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

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