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:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


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


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    print(f'{solve(H)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
H = I()
def monster(n):
    if n == 1:
        return 1
    return 1 + 2*(monster(n//2))
print(monster(H))

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import log2

print(2**int(log2(int(input())) + 1) - 1)

Submission status: Accepted

Solution code:
def solve(n):
	if n is 0:
		return 0
	return 1 + 2 * solve(n // 2)

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

Submission status: Accepted

Solution code:
H = int(input())

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

print(f(H))

Submission status: Accepted

Solution code:
import math

h = int(input())
n = int(math.log2(h))
 
a = 2
r = 2
S = (a*(r**n)-a) // (r-1)
print(S + 1)

Submission status: Accepted

Solution code:
import math

H = int(input())
n = int(math.log2(H))

a = 2
r = 2
S = (a*(r**n)-a) // (r-1)
print(S + 1)

Submission status: Accepted

Solution code:
def solve():
    H = int(input())
    cnt = 0
    ans = 0
    while H > 0:
        ans += 2**cnt
        if H == 1:
            break
        H = H // 2
        cnt += 1
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
h = int(input())
d = 0
for i in range(1000):
    if pow(2,i) <= h < pow(2,i+1):
        d = i+1
        break

print(pow(2,d)-1)

Submission status: Accepted

Solution code:
memo = {}
def f(n):
    if n==1:
        return 1
    if n in memo:
        return memo[n]
    memo[n] = 1+2*f(n//2)
    return memo[n]
print(f(int(input())))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os, sys
if os.environ.get("DEBUG") is not None:
    sys.stdin = open("in.txt", "r")
rl = sys.stdin.readline

h = int(rl())
i = 1
while True:
    if h <= 2**i - 1:
        print(2**i - 1)
        break
    i += 1

Submission status: Accepted

Solution code:
H = int(input())

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

print(c)

Submission status: Accepted

Solution code:
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    h = int(input().rstrip())

    def process(num: int):
        if num == 1:
            return 1
        else:
            count = 2 * process(num // 2)+1

        return count

    print(process(h))



if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
from math import log2

n = int(log2(int(input())))

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

Submission status: Accepted

Solution code:
def ans(n,k):
  if n==0:
    return k
  else:
    return ans(n//2,k)*2+1
N=int(input())
print(ans(N,0))

Submission status: Accepted

Solution code:
def resolve():
    H = int(input())
    cnt = 0
    mons = 1
    while H != 1:
        H = H//2
        cnt += mons
        mons *= 2
    print(cnt+mons)
    
if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

a = []
for l in sys.stdin:
    a.append(int(l))

h = a[0]
n = 0
while h > 1:
    h = math.floor(h / 2)
    n = n + 1 

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

Submission status: Accepted

Solution code:
H = int(input())
r = 0
for i in range(41):
    if H < 2**i:
        print(r)
        break
    r += 2**i

Submission status: Accepted

Solution code:
h=int(input())
hh=h
ans=1
while(1<h):
  h//=2
  ans*=2
  if h==1:
    ans+=ans

if hh==1:
  print(1)
else:
  print(ans-1)

Submission status: Accepted

Solution code:
H = int(input())
temp = 1
for i in range(40):
    temp *= 2
    if H < temp:
        print(pow(2,i+1)-1)
        break

Submission status: Accepted

Solution code:
import sys


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


def main():
    input = sys.stdin.buffer.readline
    h = int(input())
    print(solve(h))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect

H=int(input())
A=[2**x for x in range(51)]
index=bisect.bisect_right(A,H) 
print(sum(A[:index]))

Submission status: Accepted

Solution code:
import bisect

H=int(input())
A=[2**x for x in range(51)]

if H==1:
  print(1)
elif H==2:
  print(3)
else:
  index=bisect.bisect_right(A,H) 
  print(sum(A[:index]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math 

H = int(input())

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

print(calc(H))

Submission status: Accepted

Solution code:
h = int(input())

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

print(calc_need_atack_num(h))

Submission status: Accepted

Solution code:
H=int(input())

Q=[]
import math
for i in range(10000):
    if H>1:
        H=H//2
        Q.append(H)
    elif H==1:
        break
Q.sort()
S=0
a=1
for i in range(len(Q)):
    a=2*a+1
print(a)

Submission status: Accepted

Solution code:
def main():
    """"ここに今までのコード"""
    H = int(input())
    Count, atk = 1,1

    while H > atk * 2 - 1:
        atk = atk * 2
        Count = Count * 2 + 1
    
    print(Count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    def beat(hp, memo):
        if hp in memo:
            return memo[hp]
        if hp == 1:
            return 1
        else:
            child_hp = hp // 2
            cnt = 1 + beat(child_hp, memo) + beat(child_hp, memo)
            memo[hp] = cnt
            return cnt

    H = int(input())
    print(beat(H, {}))

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#memo = [0] * 100000000
#memo[1] = 1

def saiki(n):
#    global memo
    tmp = 0
    if n <= 1:
        return 1
#        return memo[1]
    else:
        tmp = int(n/2)
        return saiki(tmp) * 2 + 1
#        if memo[tmp] == 0:
#            memo[tmp] = saiki(tmp)
#        return memo[tmp]+memo[tmp]+1
    
h = int(input())
print(saiki(h))

Submission status: Accepted

Solution code:
H = int(input())
a = 1
an = 1
while a < H:
    a *= 2
    if a<=H:
        an += a
    else:
        break
print(an)

Submission status: Accepted

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

print(2**cnt-1)

Submission status: Accepted

Solution code:
h = int(input())

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

Submission status: Accepted

Solution code:
H = int(input())
a = 1
i = 1
while a < H:
    a += 2 ** i
    i += 1
print(a)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
def attacks(HP, times=1):
    if HP==0: return times-1
    
    HP //= 2
    times *= 2
    return attacks(HP,times)

h=int(input())

print(attacks(h))

Submission status: Accepted

Solution code:
def attacks(HP, times=1):
    if HP==0: return times-1
    
    HP //= 2
    times *= 2
    return attacks(HP,times)

h=int(input())
import sys
sys.setrecursionlimit(10**5)

print(attacks(h))

Submission status: Accepted

Solution code:
import math

def caracal_vs_monster():
    """
    2**0 個                       5
           　                 /       \
    2**1 個               2.5         2.5
           　             /     \      /    \
    2**2 個           1.25   1.25  1.25   1.25
          　          /    \   /   \  /  \   /   \
    2**3 個       0.625  0.625 ...
    """
    # 入力
    H = int(input())
    # H / 2 の何回目で1になるか
    count = int(math.log2(H))
    # 攻撃回数
    attack_count = 0
    for i in range(count+1):
        attack_count += 2 ** i
    return attack_count

result = caracal_vs_monster()
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(int('1'*(len(str(bin(int(input()))))-2), 2))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
H=int(input())
def f(H):
  if H==1:
    return 1
  elif H>1:
    return 2*f(H//2)+1
re=0
re=f(H)
print(re)

Submission status: Accepted

Solution code:
x=int(input())

v=len(bin(x))-2

print((1<<v)-1)

Submission status: Accepted

Solution code:
def main():
    h = int(input())
    ans = 1
    if h >= 1:
        i = 0
        while 2**i <= h:
            ans = 2**(i+1) - 1
            i += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


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


def solve():
    H = read_int()
    return count_attack(H)


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

count = 0

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

print( 2 ** count - 1 )

Submission status: Accepted

Solution code:
h = int(input())

cnt = 0
for i in range(h.bit_length()):
    cnt += 2**i
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())
p = 0
for i in range(50):
    if 2**i <= H and H < 2**(i + 1):
        p = i
        break
# print(p)
print(2**(p + 1) - 1)

Submission status: Accepted

Solution code:
H=int(input())
X=1
while X<=H:
    X*=2
print(X-1)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools

def aa(k):
    if k > 1: return 2*aa(k//2) + 1
    return 1

h = int(stdin.readline().rstrip())

print(aa(h))

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools

@functools.lru_cache(None)
def aa(k):
    if k > 1: return 2*aa(k//2) + 1
    return 1

h = int(stdin.readline().rstrip())

print(aa(h))

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import itertools

h = int(stdin.readline().rstrip())

i = 1
while True:
    h = h // 2
    if h != 0: i += 1
    if h == 0: break

print(2**i-1)

Submission status: Accepted

Solution code:
H = int(input())

def f(H):
    ans = 0
    if H > 1:
        ans += 2*f(H//2)+1
    else:
        return 1
    return ans

ans = f(H)
print(ans)

Submission status: Accepted

Solution code:
h = int( input() )

ans = 0
k = 1
while k <= h:
    ans += k
    k *= 2

print( ans )

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

cnt = 0
num = 1
while h!=1:
    cnt += num
    num *= 2
    h = h//2
else:
    cnt += num
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor

H = int(input())

c = 1
res = 0
while H > 0:
    H = floor(H/2)
    res += c
    c <<= 1

print(res)

Submission status: Accepted

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

H = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    n = 1

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


main()

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline


def rec(H):
  if H == 1:
    return 1
  # print(H)
  return 1 + 2*rec(int(H/2))


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

  print(rec(H))


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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1,10000):
    num=2**i-1
    if n<=num:
        print(num)
        break

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

H = I()

sum=0
for i in range(40):
    p = pow(2,i)
    if p > H:
        n = i-1
        break
    sum += p

print(sum)

Submission status: Accepted

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

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
H = int(input())

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

print(attack(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())
en = 1
at = 0

while H > 0:
  H //= 2
  at += en
  en *= 2
  
print(at)

Submission status: Accepted

Solution code:
h = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
H = int(input())

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

i=a=0
while H >= a:
  i += 1
  a = pow(2,i)

# print(H, i,a)
ans = pow(2,i)-1
print(ans)

Submission status: Accepted

Solution code:
import math
H=int(input())
j=1
t=1
while H!=1:
    H=math.floor(H/2)
    t*=2
    j+=t
print(j)

Submission status: Accepted

Solution code:
H =input()

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

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

Submission status: Accepted

Solution code:
n1 = int(input())

n2 = 0
n3 = 1

while n1 != 0:
    n1 = n1 // 2
    n2 += n3
    n3 *= 2

print(n2)

Submission status: Accepted

Solution code:
#153_D
h = int(input())

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

print(count)

Submission status: Accepted

Solution code:
H = int(input())

count = 0
for i in range(10**12):
    if H == 0:
        break
    H = int(H/2)
    count += 2 ** i
    

print(count)

Submission status: Accepted

Solution code:
H = int(input())

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

print(f(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
p = 1
i = 1

while h > 1:
    h = h // 2
    p += 2 ** i
    i += 1

print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())


def saiki(i):
    if i > 1:
        return 2 * saiki(i // 2) + 1
    if i == 1:
        return 1


print(saiki(n))

Submission status: Accepted

Solution code:
H = int(input())
L = len(bin(H)) - 2
ans = 0
for j in range(L):
    ans += 2 ** j
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    ans = 0
    tmp = 1
    while N > 1:
        ans += tmp
        tmp *= 2
        N //= 2
    ans += tmp
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
h = int(input())

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

print(pow(2, counter) - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

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

print(rc(h))

Submission status: Accepted

Solution code:
h = int(input())
cnt = 1
while 1 < h:
    cnt += 1
    h //= 2
    #print(h)
#print(cnt)

res = 0

for v in range(cnt):
    res += 2**v
print(res)

Submission status: Accepted

Solution code:
import math

H = int(input())

ans = 2 ** int(math.log2(H) + 1) - 1

print(ans)

Submission status: Accepted

Solution code:
H = int(input())

n = 1
ans = 0

while H > 0:
    ans += n
    n *= 2
    H //= 2

print(ans)

Submission status: Accepted

Solution code:
#26
H = int(input())
cou = 1
while H>0:
    H = int(H/2)
    cou *= 2
    
print(cou-1)

Submission status: Accepted

Solution code:
import math

H = int(input())
count = 0
atk = 0
for i in range(10 ** 12):
   
    if H == 1:
        for j in range(0,atk+1):
            count += 2 ** j
        break
    else:
        H = math.floor(H / 2)
        atk += 1

print(count)

Submission status: Accepted

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

cnt=0
for i in range(1,100):
  if h==1:
    break
  h=math.floor(h/2)
  cnt+=2**i

print(cnt+1)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

h = int(input())
print(func(h))

Submission status: Accepted

Solution code:
H=int(input())

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

print(n_attack(H))

Submission status: Accepted

Solution code:
h = int(input())
layer = 0
branch_set = 0
while True :
    if h > 1 :
        h //= 2
        layer += 1
        continue
    else :
        break

for i in range(0, layer) :
    branch_set += 2 ** i

print(branch_set + 2**layer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())
i = len(bin(H))-2
print(2**i-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

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

Submission status: Accepted

Solution code:
c= int(input())
ans =0
s = 0

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

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

print(s+1)

Submission status: Accepted

Solution code:
H = int(input())

k = 0
while 2**k <= H:
    k += 1

print(2**k - 1)

Submission status: Accepted

Solution code:
h = int(input())
cnt = 1

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

Submission status: Accepted

Solution code:
h=int(input())
#2^x<=h<2^(x+1)の時、攻撃する回数は2^0+2^1+...+2^xとなる
#xを求める
x=0
while True:
    if 2**x<=h and h<2**(x+1):
        break
    x+=1
#初項1,公比2,項数x+1の等比数列の和を求めたら終わる
print(2**(x+1)-1)

Submission status: Accepted

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

print(2**(math.floor(math.log2(N))+1)-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#a(n) = 2^ceiling(log_2(n+1))-1
import math
print(2**(math.ceil(math.log2(int(input())+1)))-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h=int(input())
def f(x):
  if x==1:
    return 1
  return f(x//2)*2

ans=f(h)
print(ans*2-1)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
cnt = 1
while N > 0:
    if N == 1:
        ans += cnt
        break
    N //= 2
    ans += cnt
    cnt *= 2
print(ans)

Submission status: Accepted

Solution code:
import sys
H = int(input())
if H == 1:
    print(1)
    sys.exit()
cnt = 1
i = 1
H //= 2
while H > 0:
    i <<= 1
    cnt += i
    H //= 2
print(cnt)

Submission status: Accepted

Solution code:
def attack(x):
  if x == 1:
    return 1 #必要攻撃回数　
  else:
    return attack(x//2) * 2 + 1

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

Submission status: Accepted

Solution code:
from collections import deque
h=int(input())
d=dict()
def solve(h):
    if h==1:
        return 1
    else:
        l=h//2
        if l not in d.keys():
            d[l]=solve(l)
        return d[l]*2+1

print(solve(h))

Submission status: Accepted

Solution code:
from collections import deque
h = int(input())
d = dict()

def solve(h):
    if h == 1:
        return 1
    else:
        l = h // 2
        if l not in d.keys():
            d[l] = solve(l)
        return d[l] * 2 + 1

print(solve(h))

Submission status: Accepted

Solution code:
H = int(input())

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
ri = lambda: int(sys.stdin.readline())

h = ri()
a = int(math.log2(h)) + 1
print(2**a - 1)

Submission status: Accepted

Solution code:
from math import log2, ceil
H = int(input())
print(2**(ceil(log2(H))+1 if log2(H).is_integer() else ceil(log2(H))) - 1)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main4()

Submission status: Accepted

Solution code:
def resolve():
    H = int(input())
    ans = 1
    while H > 0:
        ans *= 2
        H //= 2
    print(ans - 1)


resolve()

Submission status: Accepted

Solution code:
h = int(input())

def hp(n):
    if n == 1:
        ans = 1
    else:
        ans = 2*hp(n//2) + 1
    return ans
print(hp(h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

if N == 1:
    print(1)
else:
    ans = 1
    i = 1
    while N >= 2 ** i:
        ans += 2 ** i
        i += 1
    print(ans)

Submission status: Accepted

Solution code:
H = int(input())

seen = {}
seen[1] = 1

def count(n):
  if n in seen.keys():
    return seen[n]
  else:
    return 2 * count(n//2) + 1

print(count(H))

Submission status: Accepted

Solution code:
import math

h = int(input())

lg = int(math.log(h,2))

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

Submission status: Accepted

Solution code:
h=int(input())
i=h
count=1
while not i==1:
  i=int(i/2)
  count+=1
print(2**count-1)

Submission status: Accepted

Solution code:
import math

H = int(input())
count = int(math.log2(H))


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

print(result)

Submission status: Accepted

Solution code:
h = int(input())

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

print(2**cnt-1)

Submission status: Accepted

Solution code:
H = int(input())
limit = 1000000000000
ans = 0
for i in range(limit):
    if H >= 2**i:
        ans += 2**i
    else:
        break

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

h = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Jul  3 23:07:58 2020

@author: Dell
"""

n=int(input())
k=1
s=0
while n>0:
    
    n//=2
    s+=k
    k*=2
print(s)

Submission status: Accepted

Solution code:
def resolve():
    h = int(input())
    c = 0
    total = 0
    while h>0:
        total += 2**c
        h = h//2
        if h == 1:
            c += 1
            total += 2**c
            break
        c += 1
    print(total)
resolve()

Submission status: Accepted

Solution code:
H = int(input())
cnt = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

H=int(input())
print(keisan(H))

Submission status: Accepted

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