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:
def f(h):
  if h==1:
    return 1
  else:
    return f(h//2)*2+1
  
print(f(int(input())))

Submission status: Accepted

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

depth = 0
junction = 0
while H != 1:
    H = math.floor(H/2)
    junction += 2 ** depth
    depth += 1

print(junction + 2 ** depth)

Submission status: Accepted

Solution code:
h = int(input())

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

print(rec(h))

Submission status: Accepted

Solution code:
def kurakaru(h):
    if h == 1:
        return 1
    elif h > 1:
        return 1 + 2 * kurakaru(h//2)
h = int(input())
print(kurakaru(h))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
H = int(input())
count = 0
H_num = 1
while True:
    count += H_num
    H = int(H/2)
    if H == 0:
        break
    H_num *= 2
print(count)

Submission status: Accepted

Solution code:
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret


class UnionFind:
    def __init__(self, n):
        self.sz = [-1 for i in range(n)]

    # 検索
    def find(self, x):
        if self.sz[x] < 0:
            return x
        else:
            self.sz[x] = self.find(self.sz[x])
            return self.sz[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.sz[x] > self.sz[y]:
            x, y = y, x
        self.sz[x] += self.sz[y]
        self.sz[y] = x

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが含まれている集合のサイズを求める
    def size(self, x):
        return -self.sz[self.find(x)]


def main():
    h = int(input())
    t = h
    k = 0
    while t > 1:
        t //= 2
        k += 1
    k+=1
    print(2**k - 1)




            


    




    


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

if H == 1:
  print(1)

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

Submission status: Accepted

Solution code:
h = int(input())

count, m = 0, 0
while h > 0:
    count += 2 ** m
    m += 1
    h //= 2

print(count)

Submission status: Accepted

Solution code:
H=int(input())
import math
j=(math.log2(H))//1

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

Submission status: Accepted

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

Submission status: Accepted

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

while h > 0:
    h = math.floor(h / 2)
    ans *= 2

print(ans-1)

Submission status: Accepted

Solution code:
H = int(input())

def time(h):
    if h == 1:
        return 1
    elif h > 1:
        return time(h//2)*2 + 1

print(time(H))

Submission status: Accepted

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
h = i()
n = 0
while h > 0:
    h = h//2
    n += 1
print(2**n-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

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

r = func(H)
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

H = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math

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

def main():
    h = int(sys.stdin.readline())
    print(f(h))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
H = int(input())

def ref(H,d):
  d = d+1
  if 1 < H:
  	H, d = ref(H//2,d*2)
  return H, d

_, d = ref(H,0)

print(d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

def rec(x):
    if x == 0:
        return 1
    return 2 * rec(x // 2)

print(rec(h) - 1)

Submission status: Accepted

Solution code:
import math

monster_health = int(input())

hits = 0
last_hit = 1

while monster_health >= 1:
    monster_health = math.floor(monster_health / 2)
    hits += last_hit
    last_hit *= 2

print(hits)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(h+1):
    if 2**i <= h:
        c += 2**i
    else:
        break

print(c)

Submission status: Accepted

Solution code:
H=int(input())

count=0
for _ in range(48): #log_2(10^12)<12*4
  if H==1:
    print(2**(count+1)-1)
    exit()
  H=H//2
  count+=1

Submission status: Accepted

Solution code:
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

H = int(input())
n_bin = len(bin(H)[2:])

ans = 2 ** n_bin - 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
H = int(input())
N = int(np.log2(H))
C = pow(2, N+1)-1
print(C)

Submission status: Accepted

Solution code:
#ABC153D
import sys
import math
h = int(sys.stdin.readline())

n = int(math.log(h,2)) +1
#等比数列 1,2,4,8,16の和
#a=1 r=2
ans = 1*(2**n-1)
print(ans)

Submission status: Accepted

Solution code:
#ABC153D
import sys
h = int(sys.stdin.readline())

#累積 敵の数
cnt = 0
#現在の敵の数
n = 1
while n>0:
    cnt+= n
    #print(cnt)
    if h>1:
        h = h//2
        n = 2*n
    elif h==1:
        n=0
    

print(cnt)

Submission status: Accepted

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

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

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

print(attack)

Submission status: Accepted

Solution code:
def numAttack(n):
    if n == 1:
        return 1
    else:
        return 1 + numAttack(n // 2) * 2


h = int(input())
print(numAttack(h))

Submission status: Accepted

Solution code:

h = int(input())
hb=bin(h)[2:]
hbn=len(hb)
print((2**hbn-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


H = InI()

N = int(math.log(H, 2))

X = 2**(N + 1) - 1

print(X)

Submission status: Accepted

Solution code:
import math
H = map(int,input().split())

ans=sum([2**int(1+math.floor(math.log2(s)))-1 for s in H])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
count = 0
def attack(h):
  if h == 1:
    return 1
  else:
    return 2*(attack(h//2)) + 1
print(attack(h))

Submission status: Accepted

Solution code:
import math
h = int(input())
res = 0
node = 1
flag = True
while flag:
    res += node
    h = int(math.floor(h / 2))
    node *= 2
    if h == 0:
        flag = False
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

# get H
H = int(input())

pow_data = 1
pow_count = 0

while H >= pow_data:
    pow_data *= 2
    pow_count += 1

output = 0
tmp = 1
for i in range(pow_count):
    output += tmp
    tmp *= 2
print(output)

Submission status: Accepted

Solution code:
h = int(input())
count = 0
def attack(h):
  if h == 1:
    return 1
  else:
    return 2*(attack(h//2)) + 1
count = attack(h)
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
i = 0
ans = 0
while True:
  if n < 2**i:
    print(ans) 
    exit()
  ans += 2**i  
  i += 1

Submission status: Accepted

Solution code:
H = input()

i = 0
while 2 ** i <= int(H):
  i += 1
print(2 ** i - 1)

Submission status: Accepted

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

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

ans = calc(H)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


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


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

# main
H = ii()
print(attack_count(H))

Submission status: Accepted

Solution code:
x=int(input())
count=0
output=0
i=0
while x>0:
    if(x>=1):
        count=count+2**i
    i=i+1


    x=x/2
print(count)

Submission status: Accepted

Solution code:
H=int(input())
i=1
while H>=2*i:
    i=2*i
print(2*i-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
j = 0

def attack(x):
    global j
    if x == 1:
        j += 1
        return
    elif x % 2 == 1:
        x = x // 2
        j += 1
    else:
        x = int(x / 2)
        j += 1
    attack(x)

if __name__ == "__main__":
    h = int(input())
    attack(h)
    print(2 ** j - 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

h = int(input())

a = int(math.log(h, 2)) + 1

print(2 ** a - 1)

Submission status: Accepted

Solution code:
H = int(input())
k = 0
total = 0

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

m = collections.defaultdict(int)
m[h] = 1

count = 0
while 0 < len(m.keys()):
    nm = collections.defaultdict(int)
    for hp, num in m.items():
        if 1 < hp:
            nhp = hp // 2
            nm[nhp] += 2 * num
            count += num
        else:
            count += num
    m = nm

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)


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

    return solve(math.floor(x/2)) * 2 + 1

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


    print(solve(H))


if __name__ == "__main__":
  main()

Submission status: Accepted

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

H = int(input())

min = f(H)

print(min)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

# if n % 2 != 0:
#     n -= 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2^(攻撃回数)体の体力1モンスに分裂するので，等比数列の和をとればOK
H = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
H = int(input())

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

print(2 ** c - 1)

Submission status: Accepted

Solution code:
p=int(input())

count=0
ans=1

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

print(ans)

Submission status: Accepted

Solution code:
def at(h):
    if h > 0:
        h = 2 * at(h // 2) + 1
    return h
h = int(input())
h = at(h)
print(h)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
c = 0
i = 0
if h == 1:
  print(1)
else:
    while True:
      c+=1
      h = h//2
      if h <= 1:
        break
    print(sum(2**y for y in range(c+1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0
sum = 0

while n != 0:
  n //= 2
  sum += 2**count
  count += 1
  
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
hp = bin(int(input()))

n = 0
for i in range(len(hp)- 2):
    n += 2**i
    
print(n)

Submission status: Accepted

Solution code:
h = int(input())
new_h = h
pow_num = 0
ans = 0
attack = 1
preattack = 1

if h == 1:
  print("1")
  exit()
while(1):
  new_h = new_h//2
  pow_num += 1
  if new_h == 1:
    break
for i in range(pow_num):
  preattack = preattack*2
  attack += preattack
print(attack)

Submission status: Accepted

Solution code:
h = input()

def myfunc(hp: 'int') -> 'int':
    if(hp == 1):
        return 1
    elif(hp > 1):
        return int(myfunc(hp/2)) * 2 + 1
    return hp


if __name__ == '__main__':
    ans = myfunc(int(h))
    print(ans)

Submission status: Accepted

Solution code:
H = int(input())


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


print(func(H))

Submission status: Accepted

Solution code:
def attack_count(N):
    if N == 1:
        return 1
    else:
        return 2 * attack_count(N//2) + 1

H = int(input())
print(attack_count(H))

Submission status: Accepted

Solution code:
import sys
import math

H = int(input())
count = 0

if not 1 <= H or not H <= 10**12:
    print("error:1≤H≤10^12である必要があります")
    sys.exit()

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

Submission status: Accepted

Solution code:
H = int(input())
if H==1:
  print(1)
elif 2 <= H and H <= 3:
  print(3)
elif 4 <= H and H <= 7:
  print(7)
else:
  for i in range (1,43):
    if 2**(i-1)<=H and H <2**(i):
      print(2**(i)-1)
    else:
      pass

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
count = 0
count_1 = 1
count_2 = 1
while True:
    if h == 1:
        print(count_2)
        break
    else:
        h = h // 2
        count_1 = count_1 * 2
        count_2 += count_1

Submission status: Accepted

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

n = int(input())
print(f(n))

Submission status: Accepted

Solution code:
import math
h = int(raw_input())
at = 0
i = 1
while True:
    at+=i
    i = i*2
    if h==1:
        break
    h = int(math.floor(h/2.0))
print at

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

import math

a = math.log2(h)

# print(a)

b = math.floor(a)

# print(b)

c = 2**(b+1) - 1

print(c)

Submission status: Accepted

Solution code:
H = int(input())
monster_count = 1
split_count = 0
while H >= 2:
  H = int(H // 2)
  split_count += monster_count
  monster_count *= 2
print(monster_count + split_count)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()
print(2**len("{:b}".format(H))-1)

Submission status: Accepted

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

print(ans+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

# h is HP
h = int(input())

# answer
print(harf(h))

Submission status: Accepted

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

while H > 1:
  H = int(H / 2)
  i = i + 1

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

Submission status: Accepted

Solution code:
import math

n=float(input())
l=[]
cnt=0
while n >= 1:
    l.append(2**cnt)
    n=math.floor(n/2)
    cnt+=1

print(sum(l))

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
H = int(input())

h = H
attack = []
division = 0
while h >= 1:
    h /= 2
    attack.append(2**division)
    division += 1
print(sum(attack))

Submission status: Accepted

Solution code:
import numpy as np


H = int(input())
X = int(np.floor(np.log2(H)))
R = 2**(X+1)-1

print(R)

Submission status: Accepted

Solution code:
print(pow(2,int(input()).bit_length())-1)

Submission status: Accepted

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

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

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

print(attack(h))

Submission status: Accepted

Solution code:
h = int(input())

atk = 1
sum = 1
while(h != 1):
    h = h//2
    atk *= 2
    sum += atk

print(sum)

Submission status: Accepted

Solution code:
H = int(input())

cnt = 0
num = 1
length = len(str(bin(H)))-2
print(2**length-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math

N = int(input())

a = int(math.log(N, 2))

x = np.array([2 ** x for x in range(a+1)])

print(x.sum())

Submission status: Accepted

Solution code:
H = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
H = int(input())

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

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

print(Rec(a))

Submission status: Accepted

Solution code:
from sys import setrecursionlimit
setrecursionlimit(1000000)

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

h = int(input())
print(attack(h))

Submission status: Accepted

Solution code:
h = int(input())
v = 1
t = v

while True:
    if t >= h:
        break
    v *= 2
    t += v

print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    H = int(input())
    cnt = 1
    ans = 1
    while H>1:
        H = int(H/2)
        ans += 2**cnt
        cnt += 1

    print(ans)
    return

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
h = int(input())

cnt = 0

while h != 1:
	h = int(h / 2)
	cnt += 1

summery = 0

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

print(summery)

Submission status: Accepted

Solution code:
from sys import stdin

H=int(stdin.readline())

a=2
cnt=1
if H==1:
  print(1)
else:
  while a<=H :
    a=a*2
    cnt=cnt+1
  print(2**cnt-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

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

print(solve_cost(H))

Submission status: Accepted

Solution code:
h = input()
h= int(h)
num = 1<<h.bit_length()
print(num-1)

Submission status: Accepted

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

t = int(math.log2(H))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
from math import log,floor
from sys import stdin
print((2**(floor(log(int(stdin.readline()),2))+1))-1)

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
ans = 1; cnt = 1
while n>1:
	n >>=1
	ans += cnt<<1
	cnt <<=1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import math

def resolve():
    n = input()
    m = math.floor(np.log2(int(n)) + 1)
    ans = 0
    for i in range(m):
        ans += 2 ** i

    print(ans)
resolve()

Submission status: Accepted

Solution code:
# 1000000000000
# 1099511627775
N = int(input())
S = 1

while N >= S:
    S *= 2
 
print(S - 1)

Submission status: Accepted

Solution code:
h = int(input())
ans = (1 << h.bit_length()) - 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    ans = 0
    i = 0

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

    print(ans)

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def car(n):
  if n==1:
    return 1
  elif n%2==0:
    return (car(n//2)*2)+1
  else:
    return (car((n-1)//2)*2)+1
  
N=int(input())
print(car(N))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import setrecursionlimit

setrecursionlimit(1000000)

H = int(input())


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


print(f(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

h=int(input())

print(f(h))

Submission status: Accepted

Solution code:
HP=int(input())

def Caracal(x):
  if x>1:
    ans=1+Caracal(x//2)*2
  elif x==1:
    ans=1
  return ans

print(Caracal(HP))

Submission status: Accepted

Solution code:
n=int(input())
import collections
d=collections.defaultdict(int)
import sys
sys.setrecursionlimit(10000)

def luca(n):
    if n in d:
        return d[n]
    if n==1:
        return 1
    else:
        tmp=luca(n//2)*2+1
        d[n]=tmp
        return tmp

print(luca(n))

Submission status: Accepted

Solution code:
H=int(input())
monsters=[]
monsters.append([1,H])

n=0
a=H
for i in range(40):
  a=a//2
  if a>=1:
    n+=1
  else:
    break

ans=0
for i in range(n+1):
  if monsters[i][1]==1:
    ans+=monsters[i][0]
  else:
    ans+=monsters[i][0]
    monsters.append([2*monsters[i][0],monsters[i][1]//2])

print(ans)

Submission status: Accepted

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