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



Sample input:
2


Sample output:
3

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    H = int(input())
    print(f(H))

def f(x):
    if x == 1:
        return 1

    return 2 * f(x//2) + 1

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from math import floor

cache = {}


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

    if h in cache:
        return cache[h]

    new_health = h // 2
    half_number = number_to_kill(new_health)
    res = 2 * half_number + 1
    cache[h] = res
    return res


h = int(input())
print(number_to_kill(h))

Submission status: Accepted

Solution code:
def solve(h):
    if h == 0:
        return 0
    ans = 2 * solve(h // 2) + 1
    return ans


H = int(input())
print(solve(H))

Submission status: Accepted

Solution code:
n=int(input())

cnt=0
result=0

while n>1:
  n=n//2
  result+=2**cnt
  cnt+=1

print(result+2**cnt)

Submission status: Accepted

Solution code:
import math
from sys import stdin
H = int(stdin.readline().rstrip())

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

print(solve(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    j = 0
    count = 1

    while n > 1:
        n //= 2
        j += 1
        count += 2 ** j

    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

s = attack(int(input()))
print(s)

Submission status: Accepted

Solution code:
import sys, math
input = sys.stdin.readline

if __name__ == '__main__':
    H = int(input().rstrip())
    print(pow(2, int(math.log2(H))+1)-1)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
a = int(input())
def fibonaci(h):
    if h < 2:
        if h == 0:
            return 0
        return 1
    else:
        return (2*fibonaci(h/2) + 1)


print(fibonaci(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
import math

H = int(input())

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

sum = 0
for i in range(int(L)+1):
  sum += 2**i
  
print(sum)

Submission status: Accepted

Solution code:
h = int(input())
ans = 1
while h != 1:
    h //= 2
    ans *= 2
print(ans*2 - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def rec(h,cnt):
  if h==1:
    return cnt+1
  else:
    c=math.floor(h/2)
    cnt+=(rec(c,cnt))*2
    return cnt+1
h=int(input())
print(rec(h,0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

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

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

print(answer)

Submission status: Accepted

Solution code:
import math
h = int(input())
count = 0

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

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

Submission status: Accepted

Solution code:
def f(x):
    if x == 1:
        return 1
    a = f(x // 2)
    return 2*a + 1


h = int(input())


print(f(h))

Submission status: Accepted

Solution code:
h = int(input())

n = len(format(h, "b"))
print(2**n - 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

ans = 0
base = 1

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

Submission status: Accepted

Solution code:
h = int(input())

l = []
while h >= 1:
    l.append(h)
    h //= 2

print(2**len(l) - 1)

Submission status: Accepted

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

def calc(H):
  n = 1
  while H > 1:
    H = int(math.floor(H/2))
    n += 1
  print(2**(n)-1)
  
calc(H)

Submission status: Accepted

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

Submission status: Accepted

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

H = int(input())
print(f(H))

Submission status: Accepted

Solution code:
H = int(input())

def res(HP):
    if HP == 0:
        return 0
    return res(HP//2) * 2 + 1
   
print(res(H))

Submission status: Accepted

Solution code:
h = int(input())


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

print(attack(h))

Submission status: Accepted

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

H = int(input(''))
print(f(H))

Submission status: Accepted

Solution code:
h = int(input())
ans = 1
c = 1

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

print(ans)

Submission status: Accepted

Solution code:
def f(x):
    if (x==1):
        return 1
    else:
        return 2*f(x//2)+1

h = int(input())
print(f(h))

Submission status: Accepted

Solution code:
h=int(input())

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

Submission status: Accepted

Solution code:
import math
h = int(input())
n = int(math.log2(h))
ans = 0
for i in range(n+1):
  ans += 2**i
print(ans)

Submission status: Accepted

Solution code:
h = int(input())

ans = 1
total = 2
while total<=h:
  ans += total
  total = total * 2

print(ans)

Submission status: Accepted

Solution code:
import math
ans = 1
for _ in range(math.floor(math.log(int(input()), 2))):
    ans = ans * 2 + 1
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h=int(input())
a,b=1,0
while h>0:
    b+=a
    a*=2
    h//=2
print(b)

Submission status: Accepted

Solution code:
def battle(h):
  if h==1:
    return 1
  else:
    return 2*battle(h//2)+1


import math

H = int(input())
print(battle(H))

Submission status: Accepted

Solution code:
H = int(input())

count = 0

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

  return dfs(h // 2) * 2 + 1

print(dfs(H))

Submission status: Accepted

Solution code:
import math

hp=int(input())

lim =math.floor(math.log2(hp))

sum=0

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

print(sum)

Submission status: Accepted

Solution code:
H = int(input())

count = 0
while H > 0:
  H //= 2
  count += 1
  
print(sum([2**i for i in range(count)]))

Submission status: Accepted

Solution code:
import heapq

H = int(input())

count = 0

while H > 0:
  H //= 2
  count += 1
  
print(sum([2**i for i in range(count)]))

Submission status: Accepted

Solution code:
def dfs(h):
  if h == 1:
    return 1
  
  return 1 + 2*dfs(h//2)

h = int(input())
print(dfs(h))

Submission status: Accepted

Solution code:
H = int(input())

t = 1
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# coding utf-8
import math
H = int(input())

max_h = 10**12
n = 1

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

print((2**n)-1)

Submission status: Accepted

Solution code:
import math

H=int(input())
n=0
S=0

while H>0:
  
  if H>1:
    H=math.floor(H/2)
    n+=1
    S+=2**n

  if H==1:
    break

print(S+1)

Submission status: Accepted

Solution code:
import math
h=(input())

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

print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
count=0
s=0
while True:
  if a>1:
    a//=int(2)
    count+=1
    s+=2**count
  else:
    s+=1
    print(s)
    break

Submission status: Accepted

Solution code:
print(2**len(format(int(input()), "b"))-1)

Submission status: Accepted

Solution code:
import math
def solve(x):
  if x == 1:
    return 1
  elif x == 0:
    return 0
  else:
    return 2 * solve(math.floor(x/2)) + 1
x = int(input())
print(solve(x))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

H = int(input())

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

print(f(H))

Submission status: Accepted

Solution code:
from sys import setrecursionlimit

setrecursionlimit(1000000)


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

Submission status: Accepted

Solution code:
H = int(input())
i = 0
while(H!=1):
    i+=1
    H//=2
    i*=2
i+=1
print(i)

Submission status: Accepted

Solution code:
print 2**len(bin(input()))/4-1

Submission status: Accepted

Solution code:
H = int(input())

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

total += 2**cnt

  
print(total-1)

Submission status: Accepted

Solution code:
H = int(input())
kaisu = 0

while H >= 1:
  kaisu += 1
  if H > 1:
    H = H // 2
  else:
    break

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
H = int(input())
count = 0
i = 0

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

print(count)

Submission status: Accepted

Solution code:
a=int(input())
k=2
while a>=k:k*=2
print(k-1)

Submission status: Accepted

Solution code:
from math import log2
print(pow(2,int(log2(int(input()))) + 1) - 1)

Submission status: Accepted

Solution code:
import math

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

if __name__ == "__main__":
    h = int(input())
    print(caracal(h))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int):
    x = 0
    while H > 0:
        H -= 2 ** x
        x += 1

    ans = 0
    while x > 0:
        ans = 2*ans + 1
        x -= 1

    print(ans)

    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))  # type: int
    solve(H)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int):
    x = 0
    while H > 0:
        H -= 2 ** x
        x += 1

    ans = 0
    while x >= 0:
        ans = 2*ans + 1
        x -= 1

    print(ans//2)

    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))  # type: int
    solve(H)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
a = int(input())
b = math.floor(math.log2(a))
print(2**(b+1) - 1)

Submission status: Accepted

Solution code:
h = int(input())
rest = h
n_ene = 1
ans = 0
while rest>0:
    ans += n_ene
    n_ene *=2
    rest = rest//2
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2000)
def IN(): return map(int,input().split())
ans = 0; mod = pow(10,9)+7
h=int(input())
def dfs(x):
  if x==1: return 1
  else: 
    return dfs(x//2)*2+1

print(dfs(h))

Submission status: Accepted

Solution code:
H = int(input())

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

print(f(H))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

    c = 0
    while H > 0:
        c += 1
        if H < 1:
            H = 0
        else:
            H //= 2
    print(sum([2 ** i for i in range(c)]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

temp = 1
p = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

H=int(input())
cnt = 1
p = 1
import math
while H > 1:
    H = math.floor(H/2)
    cnt += 2 ** p
    p += 1
print(cnt)

Submission status: Accepted

Solution code:
H = int(input())
count = 0
ans = 0
while(H > 0):
    ans += pow(2, count)
    H = int(H / 2)
    count += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def count_attack(hp):
    if hp == 1:
        return 1
    else:
        return count_attack(hp//2) * 2 + 1

h=int(input())
print(count_attack(h))

Submission status: Accepted

Solution code:
#import time
#t1 = time.time()
h = int(input())

tmp = h
ans = 1

while tmp != 0:
    ans *= 2
    tmp = tmp //2
        
print(ans-1)

Submission status: Accepted

Solution code:
x = int(input())
y = x
d = {}
d[x] = 0
while x > 0:
    x = x // 2
    d[x] = 0
d[1] = 1
for k in sorted(d.keys()):
    if k == 0:
        d[k] = 0
    else:
        d[k] = 1 + 2 * d[k // 2]
print(d[y])

Submission status: Accepted

Solution code:
import math

def fun(x):
	if x==1:
		return 1
	return (2*fun(math.floor(x/2)))+1
n=int(input())
print(fun(n))

Submission status: Accepted

Solution code:
import math
h = int(input())
ans = 0
for i in range(int(math.log2(h))+1):
  ans += 2**i
print(ans)

Submission status: Accepted

Solution code:
H=int(input())

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

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

Submission status: Accepted

Solution code:
h = int(input())

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

print(calc(h))

Submission status: Accepted

Solution code:
H = int(input())
count = 0
monsters = 1
while H:
    H >>= 1
    count += monsters
    monsters *= 2
print(count)

Submission status: Accepted

Solution code:
h=int(input())
ans=1
while ans<h:
    ans=ans<<1|1
print(ans)

Submission status: Accepted

Solution code:
h = int(input())
n = 0
ans = 0
while True:
    if 2**n > h:
        break
    ans += 2**n
    n += 1
print(ans)

Submission status: Accepted

Solution code:
def solve(H):
    if H <= 1:
        return 1
    return 1 + 2 * solve(H//2)

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

Submission status: Accepted

Solution code:
H = int(input())
h = H
d = [0]
while h > 0:
    d.append(h)
    h = h//2
d.sort()
attack = {}
attack[0] = 0
for i in range(1,len(d)):
    attack[d[i]] = 2*attack[d[i-1]] + 1
print(attack[H])

Submission status: Accepted

Solution code:
H = int(input())

def hit_point(N):
    if N == 1:
        return 1
    else:
        return 2 * hit_point(N//2) + 1
        
print(hit_point(H))

Submission status: Accepted

Solution code:
n = int(input())


def s(a):
    if a == 0:
        return 0
    return 2*s(a//2)+1


print(s(n))

Submission status: Accepted

Solution code:
H = int(input())
x = 2
for i in range(41):
  if x <= H and x*2 > H:
    ans = x*2 - 1
    break
  x = x*2
  
if H == 1:
  ans = 1

print(ans)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
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 fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H = I()
    def dfs(x):
        if x == 1:
            return 1
        return 2 * dfs(x//2) + 1
    print(dfs(H))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
h = int(input())
n = 0
while h != 1:
    h //= 2
    n += 1
n += 1

print(2**n-1)

Submission status: Accepted

Solution code:
# coding: utf-8
h = int(input())
ans = 0
attack = 1
while (1):
    h //= 2
    ans += attack
    if h == 0:
        break
    else:
        attack *= 2

print(ans)

Submission status: Accepted

Solution code:
hp = int(input())
attack = 0
monster = 1
p = 1

for i in range(999):
    if hp == 0:
        break
    else:
        attack += 1
        hp = hp // 2

print(2 ** attack - 1)

Submission status: Accepted

Solution code:
hp = int(input())
if hp == 0:
    print(1)
    exit()

attack = 0
monster = 1
p = 1

for i in range(999):
    if hp == 0:
        break
    else:
        attack += 1
        hp = hp // 2

print(2 ** attack - 1)

Submission status: Accepted

Solution code:
from math import log2


def solve(string):
    return str(2**(1 + int(log2(int(string)))) - 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

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

    def f(x):
        if x == 1:
            return 1
        return 1 + 2 * f(x//2)
    print(f(H))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    def f(x):
        if x == 1:
            return 1
        return 2 * f(x//2) + 1
    print(f(H))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#python3

def f(h):
    cnt = 0
    while h > 0:
        h = h//2 
        cnt += 1
    return cnt

def main():
    h = int(input())
    print(pow(2, f(h)) -1)

main()

Submission status: Accepted

Solution code:
#python3

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

def main():
    h = int(input())
    print(f(h))

main()

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
h=int(input())
s=0
while(h!=0):
    s=s+1
    h=h//2
print(pow(2,s)-1)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
import math
h = int(input())
a = h
count = 0
while(a >= 1):
  count += h/a
  a /= 2
print(int(count))

Submission status: Accepted

Solution code:
d = {1: 1}

def f(x): 
    if x in d.keys(): return d[x]
    d[x] = 2 * f((x)//2) + 1

    return d[x]

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

Submission status: Accepted

Solution code:
h = int(input())

def count1(h):
    if(h==0):
        return 0
    if(h==1):
        return 1
    return 1 + 2*count1(h//2)
    
print(count1(h))

Submission status: Accepted

Solution code:
from math import log2
h = int(input())
print((1 << int((log2(2 * h + 1)))) - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

count = 0

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

ans = pow(2, count) - 1

print(ans)

Submission status: Accepted

Solution code:
h = int(input())

ans = 0
m = 1

while h > 0:
    ans += m
    h //= 2
    m *= 2

print(ans)

Submission status: Accepted

Solution code:
h = int(input())

count = 0

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

print(pow(2, count) - 1)

Submission status: Accepted

Solution code:
h = int(input())

count = 0

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

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

Submission status: Accepted

Solution code:
h = int(input())

list = []

for i in range(50):
  count = pow(2, i)
  if count > h:
    break
  list.append(count)
    
print(sum(list))

Submission status: Accepted

Solution code:
h = int(input())
i = 0
while (2**i <= h):
    i += 1
print(2**i-1)

Submission status: Accepted

Solution code:
H = int(input())

count = 1

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

print(count)

Submission status: Accepted

Solution code:
def search_H(H):
    if H==1:
        return 1
    return 2*search_H(H//2) + 1
H_1 = int(input())
print(search_H(H_1))

Submission status: Accepted

Solution code:
import math

input_num=input()
N=int(input_num)


t=1+int(math.log2(N))

def f(n):
  NUM=0
  if n==1:
    NUM=1
  else:
    NUM=f(n-1)*2+1
  return NUM

print(f(t))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h=int(input())
def cnt(n):
    if n==1:
        return 1
    else:
        return 2*cnt(n//2)+1
ans=cnt(h)
print(ans)

Submission status: Accepted

Solution code:
H=int(input())

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

ans=BCount(H)

print(ans)

Submission status: Accepted

Solution code:
H = int(input())
n = 1
c = 0

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

print(n + c)

Submission status: Accepted

Solution code:
def quick_mod(a,b):
    res=1
    while b!=0 :
        if b&1 :
            res*=a
        a*=a
        b>>=1
    return res

n=int(input())
cnt=0
while n!=0 :
    n//=2
    cnt+=1
print(quick_mod(2,cnt)-1)

Submission status: Accepted

Solution code:
import math
H=float(raw_input())
con = 0
while True:
  H = math.ceil(int(H/2))
  con += 1
  if H == 0:
    break
print 2 ** con - 1

Submission status: Accepted

Solution code:
H = int(input())

i = 0
n = 1
x = H
while x>1:
    i += n
    x //= 2
    n *= 2    
i+=n

print(i)

Submission status: Accepted

Solution code:
#input
H = int(input())

#output
answer = 0
while H > 1:
    H //= 2
    answer += 1

answer = 2**(answer+1) - 1

print(answer)

Submission status: Accepted

Solution code:
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

import math
def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = int(input())
    a = 0  #トータルの戦闘回数
    b = 0  #何回めの操作か
    while s > 0:
        s = float(s / 2)
        a += pow(2, b)
        b += 1
        if s < 1:
            break
    print(a)
    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Submission status: Accepted

Solution code:
import numpy as np
listW = [int(2 ** i) for i in range(40)]
listAns = np.array(listW).cumsum()

H = int(input())
for val in listAns:
    if H <= val:
        print(val)
        exit()

Submission status: Accepted

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

h = int(input())
print(f(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

H = int(input())
cnt = defaultdict(int)
cnt[1] = 1

def dfs(n):
  if cnt[n] == 0:
    cnt[n] = 2 * dfs(n // 2) + 1
  return cnt[n]

print(dfs(H))

Submission status: Accepted

Solution code:
h = int(input())

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

print(func(h))

Submission status: Accepted

Solution code:
H = int(input())


def F(x):
    if x == 1:
        return 1
    else:
        return 2 * F(x // 2) + 1


print(F(H))

Submission status: Accepted

Solution code:
H = int(input())

Sum = 0

for i in range(10**12):
    Sum += 2**i
    if H > 1:
        H = H // 2
    else:
        break
        
print(Sum)

Submission status: Accepted

Solution code:
h = int(input())

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

print(res)

Submission status: Accepted

Solution code:
n = int(input())
for i in range(100):
  if 2**i > n:
    print(2**i - 1)
    break

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
H = int(input())

def battle(h, cnt):
    if h == 1:
        return cnt
    return battle(h//2, cnt * 2 + 1)

print(battle(H, 1))

Submission status: Accepted

Solution code:
H = int(input())

def f(H):
	if H == 1:
		return 1
	return 2 * f(H//2)+1
	
print(f(H))

Submission status: Accepted

Solution code:
def monster(H):
  if H>1:
    return 2*monster(int(H//2))+1
  else:
    return 1

H = int(input())

print(monster(H))

Submission status: Accepted

Solution code:
from math import log2 as ln

h = int(input())
c = int(ln(h))
s = 0
for i in range(c+1):
  s += 2**i
print(s)

Submission status: Accepted

Solution code:
H=int(input())
c =0

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h = inp()
cnt = 0
tmp = h
while True:
    if tmp <= 1:
        break
    tmp //= 2
    cnt += 1
print(2**(cnt+1)-1)

Submission status: Accepted

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

b = format(h, "0b")

index = 0
ans = 0
for _b in b:
    ans += 2**index
    index += 1

print(ans)

Submission status: Accepted

Solution code:
h=int(input())

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

Submission status: Accepted

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


H = int(input())
print(f(H))

Submission status: Accepted

Solution code:
#abc153c
h=int(raw_input())
def f(x):
 if x==1:
  return 1
 return 1+f(x/2)*2
print f(h)

Submission status: Accepted

Solution code:
N = int(input())
c = 0
n = 0
while N > 0:
  N //= 2
  c += 2 ** n
  n += 1

print(c)

Submission status: Accepted

Solution code:
h = int(input())

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

print(f(h))

Submission status: Accepted

Solution code:
h = int(input())

cnt = 1
res = 0

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

print(res)

Submission status: Accepted

Solution code:
h = int(input())
i = 1
while True:
    if i > h:
        break
    i = i *2
print(i -1)

Submission status: Accepted

Solution code:
def rec(h):
    if h == 1:
        return 1
    return rec(h//2) * 2 + 1


H = int(input())
print(rec(H))

Submission status: Accepted

Solution code:
h = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

def souwa(N):
    num = 0
    for i in range(N):
        num = num + 2**i
    return num

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

print(2**count+souwa(count))

Submission status: Accepted

Solution code:
H = int(input())


def calc(n, depth=0):
    if n == 1:
        return depth + 1
    else:
        return calc(n // 2, depth + 1)


print(2 ** calc(H) - 1)

Submission status: Accepted

Solution code:
H = int(input())
n = 0
for i in range(40):
    if H == 0: break
    H //= 2
    n += 1
print(2**n-1)

Submission status: Accepted

Solution code:
h = int(input())
ret = 0
cnt = 1
while h:
    ret += cnt
    h >>= 1
    cnt <<= 1
print(ret)

Submission status: Accepted

Solution code:
N = int(input())

kai = 0
k_sum = 0
while True:
  if k_sum >= N:
    break
  k_sum += 2 ** kai
  kai += 1
  
print(k_sum)

Submission status: Accepted

Solution code:
import sys
import math
sys.setrecursionlimit(10 ** 9)
 
def func(h,ans):  
  if h == 1:
    return ans+1
  if h > 1:
    return 2 * func(math.floor(h/2),ans) + 1
  
h = int(input())
ans = 0
print(func(h,ans))

Submission status: Accepted

Solution code:
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

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