Problem:
 Score : 400 points    Problem Statement Caracal is fighting with a monster.  The health of the monster is H .  Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:   If the monster's health is 1 , it drops to 0 .  If the monster's health, X , is greater than 1 , that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor .   ( \lfloor r \rfloor denotes the greatest integer not exceeding r .)  Caracal wins when the healths of all existing monsters become 0 or below.  Find the minimum number of attacks Caracal needs to make before winning.      Constraints  1 \leq H \leq 10^{12}  All values in input are integers.         Input Input is given from Standard Input in the following format:  H       Output Find the minimum number of attacks Caracal needs to make before winning.        Sample Input 1 2      Sample Output 1 3  When Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1 .  Then, Caracal can attack each of these new monsters once and win with a total of three attacks.       Sample Input 2 4      Sample Output 2 7       Sample Input 3 1000000000000      Sample Output 3 1099511627775

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(H: int):
    ret = 0
    i = 1
    while H > 0:
        ret += i
        i *= 2
        H //= 2
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    solve(H)

if __name__ == '__main__':
    main()

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


H = int(sys.stdin.buffer.readline())
ans = 2**H.bit_length() - 1
print(ans)

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

Solution (Python):

h = int(input())

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

Solution (Python):
n=int(input())
cnt=0
i=0
while n!=0:
  n//=2
  cnt+=2**(i)
  i+=1
print(cnt)

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

Solution (Python):


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read




n = int(input())





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




print(get(n))