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 pdb
import sys
sys.setrecursionlimit(10**7)
F = sys.stdin

H = int(F.readline().rstrip())


def power(a,b):
    if b == 0:
        return 1
    elif b == 1:
        return a
    elif b%2 == 0:
        return power(a,b//2)**2
    else:
        return power(a,b//2)**2*a

ans = 0
i = 0
while power(2, i) <= H:
    ans += power(2, i)
    i += 1



print(ans)

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

Solution (Python):

import math

h = int(input())

n = int(math.log2(h))

total = 0

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

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

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

import math
a = int(math.log2(H)) +1
print(2 ** a - 1)

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

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

    if h == 0:
        break
print(ans)

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

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

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



n = int(math.log2(H))

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

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

A = []
for i in range(100):
  if sum(A) >= 10e12:
    break
  A.append(pow(2,i))
if N == 1:
  print(1)
else:
  for i in range(50):
    N = N//2
    if N <= 0:
      print(sum(A[:i+1]))
      break

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

count = 0

base = 1










while N != 0:
    count += base
    N //= 2
    base *= 2

print(count)

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

Solution (Python):
h=int(input())
num=0
now=0

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

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

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

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

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline






















def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	
	HH = inputInt()
	ans = 0

	H = []
	sin = []
	H.append(HH)

	cnte = 1
	flg = False
	while True:
		
		if cnte % 2 == 1:
			sin = []
			for i,val in enumerate(H):
				if val <= 1:
					ans += 2**(cnte-1)
					continue
				else:
					flg = True
					ans += 2**(cnte-1)
					sin.append(val//2)
					
			if flg == False:
				print(ans)
				sys.exit()
			else:
				flg = False

		else:
			H = []
			for i,val in enumerate(sin):
				if val <= 1:
					
					ans += 2**(cnte-1)
					continue
				else:
					flg = True
					ans += 2**(cnte-1)
					H.append(val//2)
					
			if flg == False:
				print(ans)
				sys.exit()
			else:
				flg = False

		cnte += 1

	




if __name__ == "__main__":
	main()

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

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

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

Solution (Python):
def Attack(i):
  goukei = 0
  if (i == 1):
    return 1
  else:
    goukei = goukei + 1
    goukei = goukei + Attack(int(i/2)) * 2
    return goukei

H = int(input())
goukei2 = Attack(H)

print(goukei2)

Solution (Python):


H=int(input())

opt=[1]
while opt[-1]<=10**12:
    opt.append(opt[-1]*2+1)

count=0
temp=1
while temp<=H:
    temp*=2
    count+=1

print(opt[count-1])

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

Solution (Python):
def main():
    H = int(input())
    i = 2
    if H > 1:
        while True:
            if H <= 2 ** i - 1:
                break
            i += 1
        print(2 ** i - 1)
    else:
        print(1)


if __name__ == '__main__':
    main()

Solution (Python):
from math import log

h=int(input())
a=0
while h:
  a+=1
  h>>=1
print(pow(2,a)-1)

Solution (Python):
nums = {1:1}
def num(k):
    if k in nums:
        return nums[k]
    else:
        nums[k] = 2 * num(k//2) + 1
        return nums[k]

h = int(input())
print(num(h))

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

Solution (Python):
import math

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

if __name__ == "__main__":
    main()

Solution (Python):
import math

hp = int(input())

num = 0
sum = 0

while (math.ceil(hp) != 1):
    hp = int(hp / 2)
    num += 1

for kk in range(num+1):
    sum += 2**kk

print(sum)

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

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

Solution (Python):
import sys
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
 
H=int(input())

cnt=0
p=0

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

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

Solution (Python):
H=int(input())
def check(h):
    if h==1:
        return(0)
    else:
        return(int(h/2))
count=0
multiply=1
while H>0:
    count+=multiply
    H=check(H)
    if H!=0:
        multiply*=2
print(count)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline






















def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	
	HH = inputInt()
	ans = 0

	H = []
	sin = []
	H.append(HH)

	cnte = 1
	flg = False
	while True:
		
		if cnte % 2 == 1:
			sin = []
			for i,val in enumerate(H):
				if val <= 1:
					ans += 2**(cnte-1)
					continue
				else:
					flg = True
					ans += 2**(cnte-1)
					sin.append(val//2)
					
			if flg == False:
				print(ans)
				sys.exit()
			else:
				flg = False

		else:
			H = []
			for i,val in enumerate(sin):
				if val <= 1:
					
					ans += 2**(cnte-1)
					continue
				else:
					flg = True
					ans += 2**(cnte-1)
					H.append(val//2)
					
			if flg == False:
				print(ans)
				sys.exit()
			else:
				flg = False

		cnte += 1

	




if __name__ == "__main__":
	main()

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

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

print(ans)

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

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

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

c=0
while(h):
    h=h//2
    c+=1

ans=(1-2**c)//(1-2)
print(ans)

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

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

print(ans)

Solution (Python):
h = int(input())
answer = 0
counter = 0
while True:
    if h == 1:
        break
    h = h // 2
    answer += pow(2, counter)
    counter += 1
print(answer + pow(2, counter))

Solution (Python):


import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy


def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z


def bfs(SS, x, y, H, W):
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" 
    for i in range(4): 
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      
      
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" 
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      
  return mlength

def brick(a,n,m,N):
  
  if not m in a[n:]:
    print(N-(m-1))
  else:
    
    brick(a,a[n:].index(m),m+1,N)




H = int(input())



H_str = bin(H)

bit = len(H_str)-3

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

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

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

Solution (Python):

h = int(input())

n = 0
a = 0
while 1:
    a = a + 2 ** n
    if h == 1:
        break
    h = h // 2
    n = n + 1

print(a)

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

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

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

print(ans)

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

count = 0

while(H!=0):
    if H==1:
        H=0
        count+=1
    else:
        H=int(H/2)
        count+=1

ans = 0

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

print(ans)

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

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

print(2**i-1)

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

Solution (Python):
N=int(input())
NB=format(N,'0b')
K=len(NB)
print(2**K-1)

Solution (Python):
from math import log2, floor

h = int(input())
t = floor(log2(h))

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

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

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

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

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

Solution (Python):
import math
h = int(input())
count = 0
while True:
  count+=1
  half = h/2
  h = math.floor(half)
  if half < 1:
    break  
    
ans = 0
plus = 1
for i in range(count):
  ans += plus
  plus *= 2

print(ans)

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H = int(read())

answer = 0
coef = 1
while H:
    answer += coef
    H //= 2
    coef *= 2

print(answer)

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

ans = 1
bit = 1

while True:
    if h == 1:
        break
    h = int(h / 2)
    bit = bit << 1
    ans += bit

print(ans)

Solution (Python):
import math
h = int(input())
if h == 1:
    print(1)
    exit()

x = 0
c = 1
while h >= 1:
    h = math.floor(h/2)
    x += c
    c *= 2

print(x)

Solution (Python):
import math

health = int(input())
depth = int(math.log2(health))
print(sum([2 ** d for d in range(depth + 1)]))

Solution (Python):
import math

H = int(input())

n = math.floor(math.log(H,2))

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

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

count = 0
for i in range(h):
    count += 2**i
    h = h//2
    if h == 0:
        break
print(count)

Solution (Python):


import math

H = int(input())
nth=0
ret = 0

while(H>0):
    H = math.floor(H/2)
    ret += math.pow(2, nth)
    nth += 1

print(int(ret))

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


n = int(input())
print(count_attack(n))

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

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

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

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

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

Solution (Python):
H = int(input())
a = H
b = 0
while a>1:
    b+=1
    a = a //2
ans = sum([2**x for x in range(b+1)])
print(ans)

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

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

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

Solution (Python):



H = int(input())




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


print(rec(H))

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

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

ans += (2 ** i)
print(ans)

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

Solution (Python):
h = int(input())
f = [0] * 100
f[0] = 1
for i in range(1, 100):
  f[i] = 1 + f[i-1] * 2
  
num = 1
while h >= 2 ** (num):
  num += 1
  
ans = f[num - 1]

print(ans)

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

Solution (Python):
h = int(input())
s = len(str(bin(h))) - 3
ans = [1]
for i in range(1,45):
    ans.append(ans[-1] * 2 + 1)

print(ans[s])

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

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

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

print count

Solution (Python):
h=int(input())
p=1
kaisu=0
while p-1<h:
    kaisu+=1
    p*=2
print(2**(kaisu)-1)

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

Solution (Python):
H = int(input())
bin_str = format(H,"b")
t = len(bin_str)
jud = 0
a = 1
result = 0
for i in range(t):
    if bin_str[i] != "0":
        jud = 1 
        break
        
if jud == 0:
    for i in range(t+1):
        result += a
        a *= 2
else:
    for i in range(t):
        result += a
        a *= 2
print(result)

Solution (Python):
h=int(input())
if h==1:
    print(1)
else:
    num=1
    while 2**num<=h:
        num+=1
    
    ans=1
    num2=1
    for i in range(num-1):
        ans+=(2**num2)
        num2+=1
    print(ans)

Solution (Python):


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

Solution (Python):
def main():

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

    return ans

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

Solution (Python):
H=int(input())
if H==1:
    print(1)
else:
    n=1
    ans=1
    while H!=1:
        H=H//2
        n*=2
        ans+=n
    print(ans)

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

Solution (Python):
import math

H = int(input())

n = math.log2(H)
n = int(n)
res = 1


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

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h = ii()
dp = [0] * 50
dp[0] = 1
for i in range(1,50):
    dp[i] = 2 * dp[i-1] + 1
ima = 0
while True:
    if 2 ** ima <= h:
        ima +=1
    else:
        break
if (2 ** ima) == h:
    print(dp[ima])
else:
    print(dp[ima-1])

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

count = 0
split = 0

mons_HP = H

while mons_HP != 0:
    if mons_HP == 1:
        mons_HP = 0
        count += 2**(split)
    else :
        crnt_HP = mons_HP
        mons_HP = int(crnt_HP/2)
        count += 2**(split)
        split += 1

print(count)

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

i = 0
while(2**i <= h):
  i += 1
i -= 1

c = 0
while(i >= 0):
  c += 2**i
  i -= 1
print(c)

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

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

import math

def count(N):
  if N==1:
    return 1
  else:
    return 2*count(math.floor(N/2)) +1

    
print(count(H))

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

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

Solution (Python):
from sys import stdin
h = int(stdin.readline().rstrip())

waru = True
warucount = 0
while waru:
    if h == 1:
        break
    h = h // 2
    warucount += 1
ones = 2 ** warucount

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

Solution (Python):

import math
H=int(input())
count=0
bunretsunum=0
while True:
    if H>1:
        H=int(math.floor(H/2))
        count=count+int(math.pow(2,bunretsunum))
        bunretsunum=bunretsunum+1
    else:
        count=count+int(math.pow(2,bunretsunum))
        break
print(count)

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

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

count=0
answer=1

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

print(answer)

Solution (Python):
import numpy as np
import math

def solve(h):
  if h == 1:
    return 1

  hh = h // 2
  return 2*solve(hh) + 1


if __name__ == "__main__":
  _h = int(input())
  ans = solve(_h)
  print(ans)

Solution (Python):
from collections import deque


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


if __name__ == '__main__':
    main()

Solution (Python):
def Attack(H: int):
    if H == 1:
        return 1
    return Attack(H // 2) * 2 + 1

H = int(input())
print(Attack(H))

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

print(ans)

Solution (Python):
import math
h = int(input())
a = 10000000000000
b = 0
for i in range(40):
    if a > h - pow(2, i) >= 0:
        a = h - pow(2, i)
        b = i

c = 0
for i in range(b+1):
    c += pow(2, i)

print(c)

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


print(f(h))

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

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

cnt = 0
lst = []
while True:
    cnt += 1
    H = int(H / 2)
    if H <= 0:
        break

ans = 0
for i in range(cnt):

    ans += (2 ** (i))
    

print(int(ans))

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

th = 1

while True:
  if N < th*2:
    break
  else:
    th *= 2

print(th*2-1)

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

Solution (Python):
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


h = fetch_int_input()[0]

count = 0
def attack(tmp_h):
    global count
    if tmp_h > 1:
        attack(tmp_h / 2)
        attack(tmp_h / 2)
        count += 1
    else:
        count += 1
        return
import math
while h >= 1:
    h = math.floor(h / 2)
    count += 1

answer = 0
for i in range(count):
    answer += pow(2, i)
print(answer)

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


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

    
    
    h = int(input())

    print(saiki(h))


main()

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

i=0

while n!=0:
    i+=1
    n=n//2

print(2**(i)-1)

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

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

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

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

count = find_count(H)
print(count)

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

cnt = 1
H //= 2
tmp = 1
while H != 0:
    H //= 2
    cnt += 2 ** tmp
    tmp += 1
print(cnt)

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

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

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

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

cnt = 1
n = 1
while True:
    n *= 2
    if n > h:
        print(cnt)
        exit()
    cnt += n

Solution (Python):


h = int(input())
i = 0
count = 0
if h == 1:
    count = 1
else:
    while(True):
        if h % 2 == 0:
            h = h // 2
        else:
            h = h // 2
        count += 2 ** i
        i += 1
        if h == 1:
            break
    count += 2 ** i
print(count)

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

import sys
sys.setrecursionlimit(10**9)
cnt = 0
def f(x):
    global cnt
    if x == 1:
        cnt += 1
        return

    else:
        x //= 2
        cnt += 1

        f(x)

f(H)
ans = 0
for x in range(cnt):
    ans += 2**x


print(ans)

Solution (Python):




import sys
input = sys.stdin.readline



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

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

    now = H
    num = 1
    res = 0

    while True:
        if now == 1:
            res += num
            break
        res += num
        now = now // 2
        num *= 2

    print(res)



main()

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

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

Solution (Python):




h = int(input())


wk_h = h
div_cnt = 0
while(wk_h >= 1):
    div_cnt = div_cnt + 1
    wk_h = wk_h // 2

at_cnt = 0
for i in range(div_cnt):
    at_cnt = at_cnt + 2 ** i
    

print(at_cnt)

Solution (Python):
from math import floor
H=int(input())
number=1
a=1
count=0
flag=True
while(flag):
   if H>=2:
      H=floor(H/2)
      number+=a*2
      a*=2
   else:
      flag=False
print(number)

Solution (Python):
import math

h = int(input())
t = 1
r = 0
while True:
    r += t
    if h == 1:
        break
    else:
        h = math.floor(h / 2)
        t *= 2
print(r)

Solution (Python):
h = int(input())
i = 1
a = 1
b = 1
c = 1

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

s = 0
t = True
for j in range(1, i-1):
    c += 2 ** j

print(c)

Solution (Python):
import sys
import math

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


sqrt = math.sqrt(H)

flag = 0
target = H
keisu = 1
attack = 1
if target == 1:
    print(attack)
else:
    while(flag == 0):
        target = target // 2
        attack += keisu * 2
        keisu = keisu*2
        if target == 1:
            flag = 1
    print(attack)

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

h = int(input())
print(get_num_of_attack(h))

Solution (Python):
import math
H = int(input())
kaisu = int(math.log2(H))+1

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

Solution (Python):
import math

H = int(input())

N = int(math.log2(H) + 1)
a = int(math.pow(2, N) - 1)

print(a)

Solution (Python):
import sys

def main():
    h = int(input().replace('\n','').split()[0])
    cnt=0
    res=0
    while(h>=1):
        h= h/2
        cnt+=1
    for i in range(cnt):
        res+=2**i
    print(res)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Solution (Python):



H = int(input())
ctr = 0

while True:
    ctr += 1
    if pow(2, ctr) > H:
        break
print((1 - pow(2, ctr)) // (-1))

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

print(2 ** (math.floor(math.log(H, 2)) + 1) - 1)

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

H = int(input())
print(ANS(H))

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

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

if H <= 0:
    print(0)
else:
    result = 1
    tmp = 1
    while H > 1:
        H = H // 2
        tmp *= 2
        result += tmp
    print(result)

Solution (Python):
H = int(input())
a = H
b = 0
while a>1:
    b+=1
    a = a //2
    
ans = sum([2**x for x in range(b+1)])
print(ans)

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

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

d = 0
n = 0
while(h > 0):
  h = (h//2)
  d += 2**n
  n += 1

print(d)

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

idx = len(bin(H)) - 2
ans = 1
for i in range(idx-1):
    ans = 2*ans + 1

print(ans)

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



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

mon_num = 1
attack_num = 0
for k in range(1000000000000):
    
    attack_num += mon_num
    
    H = math.floor(H/2)
    mon_num = mon_num*2
    
    
    if H == 1:
        attack_num += mon_num
        break
print(attack_num)

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

depth = 1
count = 0
while True:
    if h == 0:
        break
    h = h//2
    count += 2**(depth-1)
    depth += 1

print(count)

Solution (Python):
from math import log2


def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


a = int(input())
if a ==1:
    print(1)
    exit()
a = int(log2(a))


res = 4*(pow_k(2,a-1))-1
print(res)

Solution (Python):
import numpy as np
H = int(input())
print(2**(int(np.log2(H))+1)-1)

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

while True:
  h = h//2
  count += 1
  if h <= 1:
    break
    
print(1 if h==0 else 2**(count+1)-1)

Solution (Python):
H = int( input().strip() ) ;
r = 1; 

c = 0 ;
while True :
	c += r ;
	r *= 2;
	H //= 2;
	if H ==0 : break ;
print ( c ) ;

Solution (Python):
H = int(input())
ans = 1
t = 1

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

print(ans)

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

ans = 0
cnt = 0

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

print(ans)

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

h = int(input())
ans = solve(h)
print(ans)

Solution (Python):
import math

H=int(input())

a=math.log(H,2)

n=math.floor(a)

ans=0

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

print(ans)

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

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

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

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

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

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

ans = 0
cnt = 0
for i in range(h):
    if h > 1:
        h = h // 2
        cnt +=1
    else:
        break
val = [1]
for i in range(1,cnt+1):
    val.append(2**i)
print(sum(val))

Solution (Python):
import math

H = int(input())

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



curr = 1
tmp = 2
for _ in range(40):
    if tmp <= H < tmp * 2:
        print(2**(curr+1)-1)
        exit()
    else:
        curr += 1
        tmp *= 2

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

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

print(count(H))

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

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

atack = 0
mon_num = 1

while H!=1:
    atack += mon_num
    H = (H//2)
    mon_num = 2*mon_num
    

atack += mon_num

print(atack)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

h=ii()
num = 1
cnt=0
while h >0:
    if h >1:
        h = floor(h/2)
        cnt+=num
        num*=2
    else:
        h-=1
        cnt+=num

print(cnt)

Solution (Python):
h = int(input())
ret = 1
if h != 1:
    for i in range(10**6):
        h = h//2
        if h//2 < 1:
            ret += 1
            break
        else:
            ret += 1
else:
    pass
print(sum([2**i for i in range(ret)]))

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

Solution (Python):
h=int(input())
c=0
while h!=0:
    h//=2
    c+=1
A=sum([2**i for i in range(c)])
print(A)

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

Solution (Python):

import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

N = int(input().strip())

def f(n):
    return 1 + (0 if n <= 1 else 2 * f(n // 2))


print(f(N))

Solution (Python):
h = int(input())
c=1
while(1):
  if 2**c <= h:
      c+=1
  else:
      c-=1
      break

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

Solution (Python):
import math

N = int(input())
M = math.floor(math.log2(N))
print(2**(M+1)-1)

Solution (Python):



test = ""

"""
2
3
"""

"""
4
7
"""

"""
10
15
"""

"""
1000000000000
1099511627775
"""

test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()


h = int(input2())

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

s = 0
v = 1
while c:
    c -= 1
    s += v
    v *= 2


print(s)

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

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

Solution (Python):
a = int(input())
b = 0

while a:
    a //= 2
    b += 1

print(2 ** b - 1)