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

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

Solution (Python):
import math

H = int(input())

i = 1
count = 0
monster = [H, 1]
while i > 0:
  count += monster[1]
  new_monster = math.floor(monster[0] / 2)
  monster = [new_monster, monster[1] * 2]
  if new_monster == 0:
    print(count)
    break

Solution (Python):

h = int(input())
for i in range(0, 48):
    if 2**i <= h <= 2**(i+1) - 1:
        print(2**(i+1) - 1)

Solution (Python):
def attack_num(x):
    if x == 1:
        return 1
    else:
        return 1 + 2 * attack_num(x//2)


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


if __name__ == '__main__':
    main()

Solution (Python):

H = int(input())

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

print(2**c - 1)

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

res = 0
cnt = 1
while H > 0:
    H //= 2
    res += cnt
    cnt *= 2

print(res)

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

Solution (Python):
from itertools import count


def main():
    H = int(input())
    for i in count():
        if 2 ** i > H:
            print(2**i-1)
            exit()


def test():
    for H in range(1, 101):
        monster = [H]
        ans = 0
        while len(monster) > 0:
            tmp = list()
            for m in monster:
                if m != 1:
                    tmp.extend([m//2]*2)
                ans += 1
            monster = tmp
        print(ans)


def test2():
    H = 10 ** 12
    ans = 0
    while H > 1:
        H //= 2
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

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

print(ans)

Solution (Python):
def fanc(x):
    if x == 1:
        return 1
    else:
        return 2*fanc(x//2)+1


h = int(input())
print(fanc(h))

Solution (Python):
def defeat(x):
  if x == 1:
    return 1
  else:
    return 1 + 2 * defeat(x // 2)

H = int(input())
print(defeat(H))

Solution (Python):
import math

H = int(input())

k = int(math.log2(H))

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

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

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

Solution (Python):
h = int(input())
rest = [h]
c = 0
for i in range(10**100):
    if rest[i]==1:
        c += 2**i
        break
    
    rest.append(int(rest[i]/2))
    c += 2**i

print(c)

Solution (Python):

import sys
import math

def solve(H: int):
    n = int(math.log(H, 2))
    
    a = 1
    sum = 0
    for _ in range(0, n + 1):
        sum += a
        a *= 2
    
    print(sum)
    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):
import math
k=int(input())
i=0
while k>=1:
  k=math.floor(k/2)
  i+=1
print(2**i-1)

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

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

print(x-1)

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

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

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

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

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

print(attack(n = int(input())))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    h=int(input())
    cnt=1
    while h>1:
        h=h//2
        cnt+=1
    print((1-2**cnt)//(1-2))
resolve()

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

while h != 0:
    h //= 2
    att += 1
    
print(2**att - 1)

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

Solution (Python):
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]

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

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

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

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

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

    return memo[n]

memo = {1:1}

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

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

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

print(str(kaisuu(H)))

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

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

Solution (Python):
import math

h = int(input())
log = math.floor(math.log(h,2))
print(pow(2,log+1)-1)

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

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

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

Solution (Python):



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

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

if __name__ == '__main__':
    main()

Solution (Python):
H = int(input())
I = len(bin(H))-3
Sn = 2**(I+1)-1
print(Sn)

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

abc153_d()

Solution (Python):
from math import floor

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

def myAnswer(H:int) ->int:
   return (recursive(H))



def modelAnswer():
   tmp=1
def main():
   H = int(input())
   print(myAnswer(H))

if __name__ == '__main__':
   main()

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

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

Solution (Python):


h=int(input())

if h==1:
    print(1)
else:
    cnt=1
    while cnt<=h:
        cnt*=2
    print(cnt-1)

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

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

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

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

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

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

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

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

print(sum)

Solution (Python):
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    
    def rec(n, j):  
        if n == 0:
            return j
        else:
            return rec(n//2, j+1)

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

    
    cnt = 0
    for i in range(rec(h, 0)):
        cnt += 2**i

    
    print(cnt)


if __name__ == '__main__':
    main()

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

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


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

    def rec(m,j):
        if m==0:
            return 0
        else:
            return 2**j + rec(m//2,j+1)
            
        
    print(rec(n,0))

if __name__ == '__main__':
    main()

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

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


cnt = 0

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


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

print(ans)

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

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

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

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

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

Solution (Python):
import math
H = int(input())
step = 1
count = 1
while 1 < H:
  H //= 2
  step *= 2
  count += step
print(count)

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

def nested(v,depth):
    while v!=1:
        depth+=1
        v=math.floor(v/2)

    return depth+1

print(sum([2**i for i in range(nested(H,0)) ]))

Solution (Python):
import math
import sys

h = int(sys.stdin.readline().rstrip())
ans = 0
tmp = 0
while (1):
    if 2 ** tmp > h:
        break
    ans += 2 ** tmp
    tmp += 1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)
if __name__ == '__main__':
    def solve(x):
        if x == 1:
            return 1
        else:
            return 2 * solve(x // 2) + 1
    h = int(input())
    print(solve(h))

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

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

Solution (Python):

import sys
import math

def solve(H: int):
    n = int(math.log2(H))
    print(pow(2, n+1)-1)
    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):
h = int(input())
ans = -1

for i in range(100000000):
    if h+0.5<2**i:
        ans += 2**i
        break

print(ans)

Solution (Python):

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

Solution (Python):
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def f(N):
    atk = 0
    if N == 1:
        atk += 1
    else:
        atk += f(N // 2) * 2 + 1
    return atk


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print(f(N))


if __name__ == '__main__':
    main()

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

count = 1
Answer = 0

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

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

print(Answer)

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

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

ans = 0
x = 1
while True:
  ans += x
  h = h // 2
  x *= 2
  if h == 0:
    break
print(ans)

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

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

print(result)

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

cnt = 0
n = 1

while H != 1:
    cnt += n
    H //= 2
    n *= 2

print(cnt+n)

Solution (Python):
from collections import deque
h = int(input())












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

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

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

SUM = 0
for i in range(1,cnt+1):
    SUM +=  2**(i-1)

print(SUM)

Solution (Python):
def main():
    h = int(input())
    cnt = 0
    i = 0
    while h>0:
        cnt += 2**i
        i += 1
        h = h//2

    print(cnt)

if __name__ == "__main__":
    main()

Solution (Python):
import math
def main():
    H = int(input())
    print(-1*(1-2**math.floor(math.log2(H)+1)))
if __name__ == "__main__":
    main()

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

Solution (Python):
H = int(input())
def count(n):
    p = 0
    for i in range(100):
        if n != 0:
            n = int(n//2)
            p = p+(2**i)
        else:
            break
    return p
print(count(H))

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

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

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

Solution (Python):
n = int(input())
cnt = 0
while n:
    n //= 2
    cnt += 1
print(pow(2, cnt) - 1)

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

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

Solution (Python):
def  atnum(h):
    i=1
    s=1
    while(h>1):
        h=int(h/2)
        i=i*2
        s+=i
    return s
H = int(input())
print(atnum(H))

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

print(sum(num))

Solution (Python):
hp = int(input())
counter = 1
while hp>1:
    hp = hp//2
    counter = counter*2
print(counter*2-1)

Solution (Python):
H=int(input())
i=1
n=0
s=1
while ( i * 2 <= H):
  i *= 2
  s=s+i
print(s)

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

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

i = 0
ans = 1
while h:
    h = h // 2
    i += 1
for _ in range(1, i):
    ans = 2 * ans + 1
print(ans)

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

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

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

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

Solution (Python):
H = int(input())
count = 1
for i in range(100):
    if H > 1:
        H = int(H/2)
        count += 1
    else:
      break

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

Solution (Python):
import math
def Main(H):
    n = math.floor(math.log(H, 2))
    return 2**(n+1)-1

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

if __name__ == '__main__':
    main()

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

if h == 1:
    print(1)
    quit()

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

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

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

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

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

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

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

print(ans)

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

branch_cnt = 1
cnt = 0

while H != 0:
    cnt += branch_cnt
    H = H // 2
    branch_cnt *= 2

print(cnt)

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

Solution (Python):
H = int(input())
L = [H]
for i in range(1, 10 ** 2 + 1):
    L.append(2**i)
A = sorted(L)
i = A.index(H)

if (A.count(H) == 1):
    print(2 * 2**(i) - 1)
else:
    print(2 * 2**(i + 1) - 1)

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

lo=0
re=1
h=H
while  h>0:
    h=h//2
    lo += re
    re *= 2
print(lo)

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

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

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

print(ans)

Solution (Python):
import math

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

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

Solution (Python):
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())
ans = 0
cnt =0
while H > 0:
    H //=2
    ans += pow(2,cnt)
    cnt += 1
print(ans)

Solution (Python):
n = int(input())
k = 0
for i in range(48):
    k += 1
    if 2 ** i  > n:
        print(2 ** i - 1)
        break

Solution (Python):
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    H = input(int)
    h = H
    count = 0
    while 1 < h:
        h //= 2
        count += 1
    ans = 2 ** count
    temp = 1
    for x in range(count):
        ans += temp
        temp *= 2

    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

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

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

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

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

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

Solution (Python):
from collections import deque

h = int(input())
c = 0
while True:
    if h == 1:
        break
    h = h // 2
    c += 1
ans = 1
for i in range(c):
    ans = ans * 2 + 1
print(ans)

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

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

Solution (Python):



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



def int1(x):
    return int(x) - 1



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



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    h = input_int()

    result = 0
    mon_cnt = 1
    while h != 0:
        result += mon_cnt
        mon_cnt *= 2
        h = (h // 2)

    return result


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

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

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

print(2 ** count -1)

Solution (Python):
n = int(input())
i = 0
sum = 0

while n >= 2:
    n //= 2
    sum += 2 ** i
    i += 1

print(2 ** i + sum)

Solution (Python):
from pprint import pprint
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

H = ri()

def dfs(i):
	if i == 0: return 0
	return 1 + 2 * dfs(i//2)
print(dfs(H))

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

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

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

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

ans = 0

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

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

print(ans)

Solution (Python):
def judge(n):
    global num_of_split
    if n==0:
        return
    elif n%2==0:
        num_of_split+=1
        judge(n//2)
    else:
        judge(n-1)

num_of_split=0
H=int(input())
judge(H)
print(pow(2,num_of_split+1)-1)

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

for i in range(40):
    if 2**i <= h < 2**(i+1):
        print(2**(i+1)-1)
        break
    else:
        continue

Solution (Python):
h=int(input())
l=[]
i=1
flag=0
while flag!=1:
    l.append(i)
    i*=2
    if h<i:
        flag=1
print(sum(l))

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

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

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

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

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

print(f(H))

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

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

ans += 2**cnt
print(ans)

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

print(2 ** d - 1)

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

count=0

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

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

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

n = int(math.log2(H))

print(sum([2**i for i in range(n+1)]))

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

for i in range(41):
    if h < 2**i:
        print(2**i-1)
        quit()

Solution (Python):
h = int(input())
if h == 1:
    print(1)
    quit()
elif h == 2 or h == 3:
    print(3)
    quit()
for i in range(2,41):
    if h < 2**i:
        print(2**i-1)
        quit()

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

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

H = int(input())
print(attack(H))

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

Solution (Python):
h = int(input())
x = h
cnt = 0
for i in range(10**12):
  h =h//2
  cnt +=1
  if h<1:
    break
    
ans = 0
for i in range(cnt):
  ans += 2**i
print(ans)

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

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

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

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

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

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

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

num = 1
cnt = 0

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

Solution (Python):

import math
H = int(input())
c = 1
while H>1:
  H = math.floor(H/2)
  c += 1
print(sum([2**i for i in range(c)]))

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

count = 1

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

attack = [0]*count
for i in range(count):
    attack[i] = 2**i

print(sum(attack))

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())
ans = 0
cnt = 1
while h:
    h = h//2
    ans += cnt
    cnt *= 2
print(ans)

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

Solution (Python):
H=int(input())
ans=0
tmp=1


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

Solution (Python):
from math import floor

H = int(input())

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

print(f(H))

Solution (Python):
n = int(input())
cnt = 0
ans = 1

while n > 1:
  cnt += 1
  ans += 2 ** cnt
  n = n // 2
  
print(ans)

Solution (Python):












H = int(input())

ans = 0
exp = 0
while H >0:
    H = H//2
    ans += pow(2,exp)
    exp += 1

print(ans)

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

Solution (Python):
h = int(input())
num = 0
while h > 1:
    h //= 2
    num += 1
print(pow(2, num + 1) - 1)

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

Solution (Python):
import sys
import math
def input(): return sys.stdin.readline().rstrip()
def main():
    h=int(input())
    print(2**(int(math.log2(h))+1)-1)

if __name__=='__main__':
    main()

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):
h=int(input())
n=0
for i in range(41):
  if 2**i<=h and h<2**(i+1):
    n=i
    break
res=n+1
j=1
for i in range(n):
  res+=j
  j=2*j+1
print(res)

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

print(2 ** cnt - 1)

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):
H=int(input())
a=0
while 1<H:
  H=H//2
  a+=1  
print(2**(a+1)-1)

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

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

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

while H > 1:
  if H/2 - H//2 == 0:
    H = H/2
    count += 1
  else:
    H = H//2
    count += 1

print(2**(count) - 1)

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

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

Solution (Python):

H = int(input())


def iterated_power(z: int, n: int, mod=None) -> int:
    """ 繰り返し二乗法でn**kを求める（再帰処理は使わない）
    >>> p = Prime()
    >>> p.iterated_power(3, 10)
    59049
    >>> p.iterated_power(3, 10, 10)
    9
    """
    beta = bin(n)[2:]

    Z, q, t = z, 0, len(beta)
    while beta[t - q - 1] == '0':
        Z = Z * Z
        if mod is not None:
            Z = Z % mod
        q += 1
    result = Z

    for k in range(q + 1, t):
        Z = Z * Z
        if mod is not None:
            Z = Z % mod
        if beta[t - k - 1] == '1':
            result = result * Z
            if mod is not None:
                result = result % mod

    if mod is not None:
        result = result % mod

    return result


ans = iterated_power(2, H.bit_length()) - 1
print(ans)

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