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 math

h = int(input())

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

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

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

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

H = int(input())

print(num_attack(H))

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

Solution (Python):
import math
h = int(input())
if math.ceil(math.log2(h)) == math.floor(math.log2(h)):
    print(pow(2,math.ceil(math.log2(h*2)))-1)
else:
    print(pow(2,math.ceil(math.log2(h)))-1)

Solution (Python):
import numpy
H = int(input())
sum = 0
cnt = 0
if(H == 1):
	print(1)
	exit()
while H > 1:
	
	sum += 2**cnt
	H/=2
	numpy.ceil(H)
	H = int(H)
	cnt+=1
print(sum+2**(cnt))

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

if H == 1:
  print (1)
  sys.exit()
if H >= 2:
  for i in range (0,100):
    if 2 ** i > H:
      r = i
      break
ans = 2 ** r - 1
print(ans)

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

c = 0
while h > 0:
    h //= 2
    c = c * 2 + 1

print(c)

Solution (Python):
def attack(x, count):
  
  if x > 1:
    count += 1  
    x = int(x / 2)  
    count = attack(x, count)  
  return count

h = int(input())
count = attack(h, 0) + 1
print(pow(2, count) - 1)

Solution (Python):
import numpy as np
h = int(input())
def battle(x):
    if x==1: return 1
    else:
      return 1 + 2 * battle(int(np.floor(x/2)))
ans = battle(h)
print(ans)

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

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

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

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

Solution (Python):
import copy
cut=2**(len(str(bin(int(input())))[2:])-1)
cut+=cut-1
print(cut)

Solution (Python):
import math


h = int(input())

if h == 1:
    print(1)
    exit()
n = 0
while True:

    h = math.floor(h/2)
    if h <= 1:
        n += 1
        break
    else:
        n += 1

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

Solution (Python):
from math import floor, log2
H = int(input())
print(2**(floor(log2(H))+1)-1)

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

Solution (Python):


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

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













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

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

def atk(h, n):
    if(h==1):
        return n
    else:
        hnew = h//2
        n += 1
        return atk(hnew, n)

def s(n):
    return (2**n - 1)
    
print(s(atk(H,1)))

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

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

m = n+1
ans = 2**m-1
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):
h=int(input())

out=1
c=0

while h>1:
    h=h//2
    c+=1
    out+=2**c

print(out)

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

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

def atk(H,n,cnt):
  if H == 1:
    cnt += n
    print(cnt)
  elif H > 1:
    cnt += n
    atk(H//2,n*2,cnt)
        
atk(H,1,0)

Solution (Python):
def resolve():
    H = int(input())
    import math
    print(int('1'*(int(math.log2(H))+1), 2))
resolve()

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

l = len(bin(h)) - 2
ans = 0

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

print(ans)

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

Solution (Python):
import math

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

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

count = 0
for i in range(99999999999999999999999):

    
    count += 2 ** i

    q, r = divmod(H, 2)

    
    if q == 0:
        print(count)
        exit(0)

    H = q

Solution (Python):
import math 
h = int(input())
ans = 0
t = int(math.log2(h)+1)

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

Solution (Python):
import math

def main():
  H = int(input())
  
  n = math.floor(math.log(H,2))
  
  Ans = 0
  
  for i in range(n+1):
    Ans += math.pow(2,i)
    
  print(int(Ans))
  return 0

if __name__ == "__main__":
  main()

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

bin_H = format(H, 'b')

len_bin = len(bin_H)

max_digit_num = 2 ** (len_bin-1)
print(max_digit_num + max_digit_num -1)

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

print(sum)

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

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

temp = H
count = 0
ss = 0
while(temp > 1):
    temp = temp // 2
    count += 1

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

print(ss + 2 ** count)

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

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(100)

H = int(input())

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

print(f(H))

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

for i in range(1,100):
    if H < 2**i :
        print(2**i - 1)
        break

Solution (Python):
from math import floor
N = int(input())
count = 1
sums = 1
while True:
    if N == 1:
        break
    N = floor(N/2)
    count = count * 2
    sums = sums + count
print(sums)

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

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

while H != 0:
    i += N
    N *= 2
    H = int(H/2)

print(i)

Solution (Python):
X = int(input()) 
result = 2 ** (len(bin(X)) - 2) - 1

print(result)

Solution (Python):
def attack(x):
    if x <= 1:
        return 1
    else:
        ans = 0
        ans += attack(int(x / 2))
        ans *= 2
        ans += 1
        return ans

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

print(at)

Solution (Python):


def atack(tairyoku):
    if tairyoku == 1:
        return 1
    else:
        return 1 + atack(int(tairyoku/2)) * 2

H = int(input())

ans = atack(H)

print(ans)

Solution (Python):
def main():
	n = int(input())
	s = 0
	while 2 ** s <= n:
		s += 1

	print(2 ** (s) -1)


if __name__ == '__main__':
	main()

Solution (Python):
def attack(H):
    if H == 1:
        return 1
    elif H > 1:
        new_H = H // 2
        return 1 + attack(new_H) * 2

H = int(input())

print(attack(H))

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


X = int(math.log2(N))


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

print(ans)

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

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

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

Solution (Python):
import sys

H = int(input())

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

times = 1
while H != 1:
    H //= 2
    times += 1

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

print(str(ans))

Solution (Python):


h = int(input())
res = 0
counter = 0

while h > 0:
    h = h // 2
    res += 2**counter
    counter += 1

print(res)

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

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

a+=monster
print(a)

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

Solution (Python):
N = int(input())
import math
num = math.log(N, 2)

ansnum = int(num//1) + 1

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

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

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

print(attack(h))

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

import math
def get_depth(x):
  if math.floor(x/2) == 0:
    return 1
  else:
    return get_depth(math.floor(x/2)) + 1

depth = get_depth(H)

ans = 0
for i in range(depth):
  ans = ans + math.pow(2, i)

print(int(ans))

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

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

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

print(result)

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

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

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

counter = 0
hit_count = 0

while n!=1:
  n = n//2
  counter += 1
  hit_count += 2**counter
  
  
print(hit_count+1)

Solution (Python):
import math
import calendar
import fractions
import itertools

h = int(input())

a = 0

while 1:
    if 2 ** a > h:
        a -= 1
        break
    a += 1

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

print(ans)

Solution (Python):
H=int(input())
def counter(k):
    if k//2==0:
        return 1
    
    return 1+2*counter(k//2)
print(counter(H))

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

h = H
for i in range(h):
    if(h == 1):
        break
    h //=  2
n = i

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

print(ans)

Solution (Python):
H=int(input())
import math 
a=math.log2(H)
z,x=math.modf(a)

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

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

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

Solution (Python):
import math

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

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

cnt = 0
while True:
  cnt += 1
  n = i/2
  if n < 1:
    break
    
  i = n
  
ans = []
for i in range(cnt):
  ans.append(pow(2,i))
  
  
print(sum(ans))

Solution (Python):
from collections import deque

H = int(input())

l = [H]
q = deque(l)
ans = 0

def attack(ans,q):
    if len(q) == 0:
        print(2**ans-1)
        exit()
    else:
        a = q.popleft()
        if a == 1:
            ans += 1
        else:
            ans += 1
            q.append(a//2)
    return ans , q

while True:
    ans , q = attack(ans,q)

Solution (Python):

H = int(input())

v = H
values = []
while v != 0:
    values.append(v)
    v = v // 2
values = sorted(values)


cost = [0 for _ in range(len(values))]

for i in range(len(cost)):
    if i == 0:
        cost[i] = 1
    else:
        cost[i] = cost[i - 1] * 2 + 1

print(cost[-1])

Solution (Python):
H = int(input())
log = list()
x = 1
while True:
  H = H // 2
  log.append(x)
  if H == 0:
    break
  x *= 2

print(sum(log))

Solution (Python):
h=int(input())
def fun(x,ans,counter):
  
  if x<2:
    ans+=counter
    return ans
  ans+=counter
  counter+=counter
  return fun(x//2,ans,counter)
print(fun(h,0,1))

Solution (Python):

import sys

def solve(H: int):
    ans=len(str(bin(H)))-2
    print(2**ans-1)

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

for i in range(50):
    if 2 ** i <= h:
        continue
    else:
        break

ans = 0

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

print(ans)

Solution (Python):

def solve(H):
	if H == 1:
		return 1
	
	ans = 0
	count = 1	
				
	while H >= 1:
		ans += count
		
		H = H // 2
		count *= 2
		
	return ans
	
H = int(input().strip())
print(solve(H))

Solution (Python):

import math
N = int(input())
ans = 0
for i in range(int(math.log(N, 2))+1):
    ans += 2 ** i

print(ans)

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

AN=0

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

print(2**AN-1)

Solution (Python):
from sys import stdin
H = int(stdin.readline().rstrip())
ans = 1
while ans <= H:
    ans = ans * 2
print(ans-1)

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

print(ans)

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

while h >= fix:
  fix *= 2

print(fix - 1)

Solution (Python):

H = int(input())
att = 0
monster_cnt = 1
while H != 1:
    H = int(H / 2)
    att += monster_cnt
    monster_cnt *= 2
print(att * 2 + 1)

Solution (Python):
hp = int(input())
pow_2 = len(bin(hp)) - 3

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

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

b=0
for i in range(c):
  b+=2**i
print(b)

Solution (Python):
def resolve():
    d = 1
    h = int(input())
    s = h
    a =0
    while 1 <= s:
        a += d
        s /=2
        d*=2
    print(a)

resolve()

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

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

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

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

hits = 0
steps = 1
while H != 1:
    H //= 2
    steps += 1
for x in range(steps):
    hits += pow(2, x)

print(hits)

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

i = 0
while 0 < H:
    i += 1
    H //= 2

print((2**i-1))

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

div_count = 0
add = 0
total_count = 0

while True:
    if h == 1:
        break
    h = h // 2
    if add == 0:
        div_count += 1
        add += 1
    else:
        div_count += add * 2
        add *= 2

if div_count == 0:
    total_count = 1
else:
    total_count = div_count + (add * 2)

print(total_count)

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

if h == 1:
  print(1)
  sys.exit()
cnt = 0
while h != 1:
  h = h // 2
  cnt += 1
  
print(2**(cnt+1)-1)

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

N = 0
flag = True
while flag:
  if H<2**N:
    flag = False
  else:
    N += 1

ans = 2**N - 1

print(ans)

Solution (Python):

H = int(input())

a = 1
b = 0
while ( a <= H):
    a *= 2
    b += 1

print(2**b-1)

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

num = 0
while True:
    if H == 1:
        break
    else:
        if H % 2 == 0:
            H = H // 2
            num += 1
        else:
            H = (H - 1) // 2
            num += 1
print(pow(2, num + 1) - 1)

Solution (Python):



h = int(input())

c = 0

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

print(2**c - 1)

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

dp = [0, 1]

for i in range(2, 100001):
    x = 1 + 2 * dp[i // 2]
    dp.append(x)


if h < 100001:
    print(dp[h])



else:
    l = []
    y = h
    while y >= 100001:
        l = [y] + l
        y = y// 2
    ans = 1 + 2 * dp[l[0] // 2]
    if len(l) > 1:
        for i in range(len(l) - 1):
            ans = 1 + 2 * ans
    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):


h = int(input())
out = 1
count = 1

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

print(out)

Solution (Python):
import sys
import math
H = int(input())
if H == 1:
    print(H)
    sys.exit()
n = 0
while H!=1:
    H = H//2
    n += 1
print(2**(n+1)-1)

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


while(1):
    kaisuu = kaisuu + kazu
    if(h>1):

        kazu = kazu * 2
        h = h//2
    else:

        print(kaisuu)
        break

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

count = 1
while True:
    if not H > 1:
        break
    H = H // 2
    count += 1

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

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

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

print(ans)

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

while True:
    if h != 1:
        h = int(h/2)
        count += 1
    else:
        break

x = [2**i for i in range(count+1)]
print(sum(x))

Solution (Python):
import numpy as np

H = int(input())

if H == 1:
  print("1")
else:
  c = 0
  h = H
  while(h>1):
    h //= 2
    c += 1
  
  p = 1
  q = 0
  for i in range(c+1):
    q += p
    p *= 2
  print(q)

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

Solution (Python):
import math

h = int(input())

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


print(ans)

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

x=int(input())
print(f(x))

Solution (Python):
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t 
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

H, = I()
c = 0
while H > 0:
    H = H//2
    c += 1
ans = 0
for i in range(c):
    ans += 2**i
print(ans)

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

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

i = 1
ans = 0
while True:
    if h == 1:
        ans += 2 ** (i - 1)
        break
    else:
        h = h // 2
        ans += 2 ** (i - 1)
    i += 1

print(ans)

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

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

print(ans)

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

ans=0
counter=1
for i in range(50):
    if n>0:
        ans+=2**i
        n=n//2
    elif n==0:
        break
print(ans)

Solution (Python):
def main():
    import math
    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H,2))
        ans = 0
        for i in range(count):
            ans += 2**(i)
            if i == count-1:
                ans += 2**(i+1)
        print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
h=int(input())
cnt=1; ans=0
def attack(h,cnt,ans):
    if h==1: return ans+1
    h=h//2; cnt*=2; ans+=cnt
    return attack(h,cnt,ans)
print(attack(h,cnt,ans))

Solution (Python):
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
H = int(input())
n = 0
while True:
    if H == 1: 
        break
    n = n + 1
    H= H // 2

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

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

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

Solution (Python):
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

H = num()
e_num = 1
enemies = [H]
ans = 0
while 1:
    if H == 1:
        ans += e_num
        break
    H = math.floor(H/2)
    ans += e_num
    e_num *= 2
print(ans)

Solution (Python):
H = int(input())
cnt = len(format(H, 'b'))
print(2**cnt - 1)

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

i = 0
while True:
    tmp = pow(2, i)
    if H < tmp:
        break
    i += 1


print(pow(2,i)-1)

Solution (Python):
h = int(input())
n = 0
l = []
ans = 1
for i in range(42):
    l.append(2**i)

for i in range(1,41):
    if l[i]<=h<l[i+1]:
        ans=sum(l[:i+1])

print(ans)

Solution (Python):


h = int(input())

ans, cnt = 0, 1 
while h != 0:
    ans += cnt
    h //= 2
    cnt *= 2

print(ans)

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

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

print(count + 2**set_count)

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

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

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

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

print(cnt * 2 - 1)

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

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

count = 0
width = 0

while(1):
  if h == 1:
    count += pow(2,width)
    break
  if h >=2:
    if h%2 == 1:
      h = h-1
    h = h//2
    count += 1*pow(2,width)
    width += 1
print(count)

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

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

if 2**i==H:
  for k in range(i+1):
    Sum+=2**k
else:
  for k in range(i):
    Sum+=2**k
print(Sum)

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

ans = 0
while True:
    if H < 2 ** ans:
        break
    else:
        ans += 1

print((2 ** ans) - 1)

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

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

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

Solution (Python):


import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False


        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
    


    h = int(lines[0])

    return (h, )

def solve(h, ):

    current_h = h
    total_count = 1
    current_count = 1
    while True:
        
        if current_h == 1:
            break

        current_h = current_h // 2
        current_count = 2 * current_count
        total_count = total_count + current_count


    result = total_count 

    return result

def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()

Solution (Python):
import collections
import itertools as it
import math
import numpy as np









H = int(input())

c = 0
for i in range(10000000):
    c += 1
    if H == 1:
        break
    else:
        H = H // 2

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

print(ans)

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

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

Solution (Python):
h = int(input())
cnt=0
while h>0:

  if h==1:
    h=0
  else:
    h = h//2
  
  cnt+=1
ans=0
for i in range(cnt):
  ans+=2**i
print(ans)

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

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

while(1):
    if h >= 2**(i+1) and h < 2**(i+2):
        print(2**(i+2)-1)
        exit(0)

    i = i + 1

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

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

ans = 0
i = 1
while(h != 0):
    if h != 1:
        h = int(h/2)
    else:
        h = 0
    ans +=  i
    i *= 2
print(ans)

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

Solution (Python):
import sys

input = sys.stdin.readline
H = int(input())

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

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

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

h = int(input())
cnt = 0

while True:
    if h == 1:
        break

    h //= 2
    cnt +=1

ans = 0

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

print(ans)

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

Solution (Python):
def main():
    h=int(input())
    p=0
    n=0
    while h > 0:
        n+=2**p
        p+=1
        h>>=1
    print(n)

main()

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

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

bin_h = bin(h)
bin_h = bin_h[:2] + bin_h[2:].replace("0", "1")
print(int(bin_h, 2))

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

def attack(h, memo):
    if h == 1:
        return 1
    if h in memo:
        return memo[h]
    count = 1 + 2 * attack(h // 2, memo)
    memo[h] = count
    return count

memo = {}
print(attack(h, memo))

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

def count_attack(hp):
    count = 0        
    if hp == 2 or hp == 3:
        return 3
    else:
        
        count += 1
        hp_child = hp //2
        count += 2 * count_attack(hp_child)
        return count

if n == 1:
    print(1)
else:
    print(count_attack(n))

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

Solution (Python):
H = int(input())
d = [] 
ruijou = 1
while H >= ruijou:
  d.append(ruijou)
  ruijou *= 2
print(sum(d))

Solution (Python):
import sys
from functools import lru_cache
sys.setrecursionlimit(20000)


class Dp:

    def __init__(self, size):
        self.size = size

    @lru_cache(maxsize=None)
    def calc(self, n):
        if n == 1:
            return 1
        return self.calc(n//2) * 2 + 1


def main():
    h = int(input())
    dp = Dp(h)
    result = dp.calc(h)
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):

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

print(n)

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

ans = 1

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

while True:
    tmp = ans*2 + 1
    if H > ans and H <= tmp:
        print(tmp)
        exit()
    else:
        ans = tmp

Solution (Python):
import math

H = int(input())

depth=0

while H>=1:
	depth+=1
	H=math.floor(H/2)
  
num = sum([2**i for i in range(depth)])

print(num)

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

i = 0
sol=1
while N>1:
  N=N//2
  i+=1
  sol+=2**i


  




print( sol )

Solution (Python):
import math

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


if __name__ == '__main__':
    main()

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

@lru_cache(maxsize=None)
def func(h):
  if h==1:
    return 1
  return func(h//2)*2+1

print(func(h))

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(input()) 
def ifn(): return float(input()) 
def isn(): return input().split() 
def imn(): return map(int, input().split()) 
def fmn(): return map(float, input().split()) 
def iln(): return list(map(int, input().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, input().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD

H = iin()

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

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

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

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

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

print(ans)

Solution (Python):
H=int(input())
h=H//2
a=1
b=1
c=1
for i in range(H):
    if h==1:
        break
    if h==0:
        break
    h=h//2
    a+=1
for i in range(a):
    c=2*c
    b=b+c
if H>1:
    print(b)
else:
    print(1)

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

for i in range(100000000): 
    if(2**i<=H and H<2**(i+1)):
        print(2**(i+1)-1)
        break

Solution (Python):

"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""


H=int(input())

N=1
c=1
while(H>1):
    H=H//2
    c*=2
    N+=c

print(N)

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

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

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

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

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

cnt = 1
ans = 1

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

print(ans)

Solution (Python):

H = int(input())

def action(H, cnt):
    cnt +=1
    
    if H==1:
        return cnt
    else:
        cnt = action(H//2, cnt*2)
        return cnt

cnt = action(H, 0)
print(cnt)

Solution (Python):
H = int(input())
counter = 0
pv = [1,H]
while pv[1] >1:
  counter += pv[0]
  pv[0] *=2
  pv[1] = pv[1]//2
print(counter+pv[0])

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

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

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

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


print(ans)

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

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


def divCount(n, cnt = 0):
    if n <= 1:
        return cnt
    return divCount(int(n / 2), cnt + 1)

attackCount = 0
for i in range(0, divCount(H)+1):
    attackCount += pow(2, i)

print(attackCount)

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

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