codeforces/558C_chem_2.py
def calculate(self):
        """ Main calcualtion function of the class """

        valid = set()
        stp = [0] * self.MAX
        first = 1
        for vol in self.list:
            new_valid = set()
            steps = 0
            prev = 1
            while vol > 0:
                if (first or vol in valid):
                    if prev % 2 == 1:
                        ssteps = steps + 1
                        svol = vol << 1
                        while svol <= self.MAX:
                            new_valid.add(svol)
                            stp[svol] += ssteps
                            svol <<= 1
                            ssteps += 1
                    new_valid.add(vol)
                    stp[vol] += steps
                prev = vol
                vol >>= 1
                steps += 1
            if not first:
                valid.intersection_update(new_valid)
            else:
                valid.update(new_valid)
            first = 0

        result = None
        for n in valid:
            if result is None or result > stp[n]:
                result = stp[n]

        return str(result)
 Main calcualtion function of the class 
Main calcualtion function of the class
Main calcualtion function of the class
def calculate(self):
        valid = set()
        stp = [0] * self.MAX
        first = 1
        for vol in self.list:
            new_valid = set()
            steps = 0
            prev = 1
            while vol > 0:
                if (first or vol in valid):
                    if prev % 2 == 1:
                        ssteps = steps + 1
                        svol = vol << 1
                        while svol <= self.MAX:
                            new_valid.add(svol)
                            stp[svol] += ssteps
                            svol <<= 1
                            ssteps += 1
                    new_valid.add(vol)
                    stp[vol] += steps
                prev = vol
                vol >>= 1
                steps += 1
            if not first:
                valid.intersection_update(new_valid)
            else:
                valid.update(new_valid)
            first = 0
        result = None
        for n in valid:
            if result is None or result > stp[n]:
                result = stp[n]
        return str(result)
def calculate ( self ) : valid = set ( ) stp = [ 0 ] * self . MAX first = 1 for vol in self . list : new_valid = set ( ) steps = 0 prev = 1 while vol > 0 : if ( first or vol in valid ) : if prev % 2 == 1 : ssteps = steps + 1 svol = vol << 1 while svol <= self . MAX : new_valid . add ( svol ) stp [ svol ] += ssteps svol <<= 1 ssteps += 1 new_valid . add ( vol ) stp [ vol ] += steps prev = vol vol >>= 1 steps += 1 if not first : valid . intersection_update ( new_valid ) else : valid . update ( new_valid ) first = 0 result = None for n in valid : if result is None or result > stp [ n ] : result = stp [ n ] return str ( result )
Main calcualtion function of the class
Main calcualtion function of the class
""" Main calcualtion function of the class """
self