solutions: ["class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\treturn sum((bin(x).count('1') for x in nums)) + len(bin(max(nums))) - 3\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tadd_count = sum((bin(v).count('1') for v in nums))\n\t\tmul_count = len(bin(max(nums))) - 3\n\t\treturn add_count + mul_count\n\n\tdef minOperations_my(self, nums: List[int]) -> int:\n\t\tadd_sum = mul_maxi = 0\n\t\tfor value in nums:\n\t\t\tc1 = c2 = 0\n\t\t\twhile value > 1:\n\t\t\t\tif value & 1:\n\t\t\t\t\tc1 += 1\n\t\t\t\tc2 += 1\n\t\t\t\tvalue >>= 1\n\t\t\tadd_sum += c1 + value\n\t\t\tmul_maxi = max(mul_maxi, c2)\n\t\treturn add_sum + mul_maxi\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tm = [bin(x)[2:].zfill(32) for x in nums]\n\t\tret = 0\n\t\tfor i in range(32):\n\t\t\tcnts = sum([1 if x[i] == '1' else 0 for x in m])\n\t\t\tret += cnts\n\t\t\tif ret > 0:\n\t\t\t\tret += 1\n\t\t\t\tpass\n\t\t\tpass\n\t\treturn ret - 1\n", "class Solution:\n\n\tdef minOperations(self, a: List[int]) -> int:\n\t\tans = 0\n\t\tmx = 0\n\t\tfor x in a:\n\t\t\tcnt = 0\n\t\t\twhile x:\n\t\t\t\tif x % 2:\n\t\t\t\t\tans += 1\n\t\t\t\tcnt += 1\n\t\t\t\tx //= 2\n\t\t\tmx = max(mx, cnt)\n\t\treturn max(ans + mx - 1, 0)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef highestBit(x):\n\t\t\ti = 0\n\t\t\twhile x:\n\t\t\t\ti += 1\n\t\t\t\tx = x >> 1\n\t\t\treturn i\n\n\t\tdef numberOfBits(x):\n\t\t\ti = 0\n\t\t\twhile x:\n\t\t\t\ti += 1\n\t\t\t\tx = x & x - 1\n\t\t\treturn i\n\t\tdoublings = max(map(highestBit, nums))\n\t\tprint(doublings)\n\t\tadds = sum(map(numberOfBits, nums))\n\t\tprint(adds)\n\t\treturn doublings - 1 + adds\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\tmax_num = 0\n\t\tfor n in nums:\n\t\t\tmax_num = max(max_num, n)\n\t\t\twhile n > 0:\n\t\t\t\tn = n & n - 1\n\t\t\t\tops += 1\n\t\twhile max_num > 1:\n\t\t\tmax_num >>= 1\n\t\t\tops += 1\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations_1(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\twhile not all((n == 0 for n in nums)):\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n % 2 != 0:\n\t\t\t\t\tnums[i] = n - 1\n\t\t\t\t\tops += 1\n\t\t\tif all((n == 0 for n in nums)):\n\t\t\t\tbreak\n\t\t\tnums = [n // 2 for n in nums]\n\t\t\tops += 1\n\t\treturn ops\n\n\tdef minOperations_2(self, nums: List[int]) -> int:\n\t\top_1 = 0\n\t\top_2 = 0\n\t\tfor n in nums:\n\t\t\top_2_cur = 0\n\t\t\twhile n > 0:\n\t\t\t\tif n % 2 != 0:\n\t\t\t\t\top_1 += 1\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\top_2_cur += 1\n\t\t\t\t\tn = n // 2\n\t\t\top_2 = max(op_2, op_2_cur)\n\t\treturn op_1 + op_2\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top1 = 0\n\t\top2 = 0\n\t\tfor i in range(31):\n\t\t\tfor n in nums:\n\t\t\t\tif n & 1 << i != 0:\n\t\t\t\t\top1 += 1\n\t\t\t\t\top2 = i\n\t\treturn op1 + op2\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\taddOneOperations = 0\n\t\thighestSetBit = 0\n\t\tfor bit in range(31):\n\t\t\tfor num in nums:\n\t\t\t\tif num & 1 << bit != 0:\n\t\t\t\t\taddOneOperations += 1\n\t\t\t\t\thighestSetBit = bit\n\t\treturn addOneOperations + highestSetBit\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif nums == [0]:\n\t\t\treturn 0\n\t\tcount = 0\n\t\tmax_bits = 0\n\t\tfor n in nums:\n\t\t\tbits = 0\n\t\t\twhile n:\n\t\t\t\tcount += n & 1\n\t\t\t\tbits += 1\n\t\t\t\tn >>= 1\n\t\t\tmax_bits = max(max_bits, bits)\n\t\treturn count + max_bits - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tadd_sum = mul_maxi = 0\n\t\tfor value in nums:\n\t\t\tc1 = c2 = 0\n\t\t\twhile value > 1:\n\t\t\t\tif value & 1:\n\t\t\t\t\tc1 += 1\n\t\t\t\tc2 += 1\n\t\t\t\tvalue >>= 1\n\t\t\tadd_sum += c1 + value\n\t\t\tmul_maxi = max(mul_maxi, c2)\n\t\treturn add_sum + mul_maxi\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\thb = 0\n\t\tans = 0\n\t\tfor n in nums:\n\t\t\tfor i in range(32):\n\t\t\t\tif n & 1 << i:\n\t\t\t\t\tans += 1\n\t\t\t\t\tif i > hb:\n\t\t\t\t\t\thb = i\n\t\treturn ans + hb\n", "import collections\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tsum = 0\n\t\tfor num in nums:\n\t\t\tsum += collections.Counter(bin(num))['1']\n\t\tsum += len(bin(max(nums))) - 3\n\t\treturn sum\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef n1b(x):\n\t\t\tans = 0\n\t\t\twhile x:\n\t\t\t\tx &= x - 1\n\t\t\t\tans += 1\n\t\t\treturn ans\n\n\t\tdef hi(x):\n\t\t\tans = 0\n\t\t\twhile x:\n\t\t\t\tx >>= 1\n\t\t\t\tans += 1\n\t\t\treturn ans\n\t\tmaxshift = 0\n\t\ttog = 0\n\t\tfor n in nums:\n\t\t\tmaxshift = max(maxshift, hi(n))\n\t\t\ttog += n1b(n)\n\t\tmaxshift = max(0, maxshift - 1)\n\t\treturn maxshift + tog\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tx = [0] * len(nums)\n\t\tcounts = 0\n\t\twhile 1:\n\t\t\tcounts += sum((n % 2 for n in nums))\n\t\t\tnums = [n // 2 for n in nums]\n\t\t\tif nums == x:\n\t\t\t\treturn counts\n\t\t\tcounts += 1\n\n\t\tdef div(l):\n\t\t\tfor i in range(len(l)):\n\t\t\t\tif sum(l) == 0:\n\t\t\t\t\treturn None\n\t\t\t\tl[i] *= 2\n\t\t\treturn l\n\n\t\tdef mi(l):\n\t\t\tfor i in range(len(l)):\n\t\t\t\tl[i] += 1\n\t\t\treturn l\n\t\tq = deque()\n\t\tq.append([0] * len(nums))\n\t\td = 0\n\t\twhile q:\n\t\t\td += 1\n\t\t\tfor i in range(len(q)):\n\t\t\t\tx = q.popleft()\n\t\t\t\tj = x.copy()\n\t\t\t\tprint(x)\n\t\t\t\tif x == nums:\n\t\t\t\t\treturn d\n\t\t\t\ty = div(j)\n\t\t\t\tif y != None:\n\t\t\t\t\tq.append(y)\n\t\t\t\tq.append(mi(x))\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ta = m = 0\n\t\tfor i in nums:\n\t\t\ta += bin(i).count('1')\n\t\t\tm = max(m, len(bin(i)) - 3)\n\t\treturn a + m\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_half_ops = 0\n\n\t\tdef find_odd_ops_req(num):\n\t\t\tnonlocal max_half_ops\n\t\t\tresult = 0\n\t\t\thalf_ops = 0\n\t\t\twhile num:\n\t\t\t\tresult += num & 1\n\t\t\t\thalf_ops += 1\n\t\t\t\tnum = num >> 1\n\t\t\tmax_half_ops = max(max_half_ops, half_ops - 1)\n\t\t\treturn result\n\t\tresult = 0\n\t\tfor num in nums:\n\t\t\tresult += find_odd_ops_req(num)\n\t\treturn result + max_half_ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(n_add, n_mul) = (0, 0)\n\t\tfor num in nums:\n\t\t\tc_mul = 0\n\t\t\twhile num > 1:\n\t\t\t\tn_add += num % 2\n\t\t\t\tnum //= 2\n\t\t\t\tc_mul += 1\n\t\t\tif num == 1:\n\t\t\t\tn_add += 1\n\t\t\tn_mul = max(n_mul, c_mul)\n\t\treturn n_add + n_mul\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(op_0, op_1) = (0, 1)\n\t\tfor num in nums:\n\t\t\tb_len = 0\n\t\t\twhile num:\n\t\t\t\top_0 += num & 1\n\t\t\t\tnum >>= 1\n\t\t\t\tb_len += 1\n\t\t\top_1 = max(op_1, b_len)\n\t\treturn op_0 + op_1 - 1\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = max([int(math.log(x) / math.log(2)) for x in nums if x > 0])\n\t\tfor n in nums:\n\t\t\twhile n:\n\t\t\t\tif n % 2:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\tn //= 2\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxTwos = 0\n\t\tones = 0\n\t\tfor num in nums:\n\t\t\t(count, left) = self.getCount(num)\n\t\t\tmaxTwos = max(maxTwos, count)\n\t\t\tones += left\n\t\treturn ones + maxTwos\n\n\tdef getCount(self, num):\n\t\tcount = 0\n\t\todd = num % 2\n\t\tif num % 2 == 1:\n\t\t\tnum -= 1\n\t\twhile num > 1:\n\t\t\todd += num % 2\n\t\t\tnum //= 2\n\t\t\tcount += 1\n\t\treturn (count, num + odd)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(ans, largest) = (0, 0)\n\t\tfor num in nums:\n\t\t\tlargest = max(largest, num)\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\tans += 1\n\t\t\t\tif num > 0:\n\t\t\t\t\tnum = num // 2\n\t\twhile largest > 1:\n\t\t\tans += 1\n\t\t\tlargest = largest // 2\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttwos = 0\n\t\tones = 0\n\t\tfor n in nums:\n\t\t\tmul = 0\n\t\t\twhile n:\n\t\t\t\tif n % 2:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tones += 1\n\t\t\t\telse:\n\t\t\t\t\tn //= 2\n\t\t\t\t\tmul += 1\n\t\t\ttwos = max(twos, mul)\n\t\treturn ones + twos\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef numOperations(x):\n\t\t\t(n1, n2) = (0, 0)\n\t\t\twhile x:\n\t\t\t\tif x & 1:\n\t\t\t\t\tn1 += 1\n\t\t\t\t\tx -= 1\n\t\t\t\telse:\n\t\t\t\t\tn2 += 1\n\t\t\t\t\tx //= 2\n\t\t\treturn (n1, n2)\n\t\t(n1, n2) = (0, 0)\n\t\tfor x in nums:\n\t\t\t(x1, x2) = numOperations(x)\n\t\t\tn1 += x1\n\t\t\tn2 = max(n2, x2)\n\t\treturn n1 + n2\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tones = 0\n\t\ttwoes = 0\n\t\tfor i in nums:\n\t\t\tc = 0\n\t\t\twhile i:\n\t\t\t\tif i % 2:\n\t\t\t\t\ti -= 1\n\t\t\t\t\tones += 1\n\t\t\t\telse:\n\t\t\t\t\ti //= 2\n\t\t\t\t\tc += 1\n\t\t\ttwoes = max(twoes, c)\n\t\treturn ones + twoes\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef operate(n):\n\t\t\tmax_ = 0\n\t\t\tans = 0\n\t\t\tk = 0\n\t\t\twhile n > 0:\n\t\t\t\tk += 1\n\t\t\t\tans += n % 2\n\t\t\t\tn = n // 2\n\t\t\tmax_ = max(max_, k - 1)\n\t\t\treturn (max_, ans)\n\t\tans = 0\n\t\tmax_ = 0\n\t\tfor n in nums:\n\t\t\t(m, o) = operate(n)\n\t\t\tmax_ = max(max_, m)\n\t\t\tans += o\n\t\treturn ans + max_\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxTwos = 0\n\t\ttotalOnes = 0\n\t\tfor num in nums:\n\t\t\t(twos, ones) = self.getCount(num)\n\t\t\tmaxTwos = max(maxTwos, twos)\n\t\t\ttotalOnes += ones\n\t\treturn totalOnes + maxTwos\n\n\tdef getCount(self, num):\n\t\ttwos = 0\n\t\tones = 0\n\t\twhile num > 1:\n\t\t\tones += num % 2\n\t\t\tnum //= 2\n\t\t\ttwos += 1\n\t\treturn (twos, ones + num)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttotOddRem = 0\n\t\tmax2Power = 0\n\t\tfor x in nums:\n\t\t\tpow2 = 0\n\t\t\twhile True:\n\t\t\t\ttotOddRem += x & 1\n\t\t\t\tif x > 1:\n\t\t\t\t\tpow2 += 1\n\t\t\t\t\tx >>= 1\n\t\t\t\telse:\n\t\t\t\t\tbreak\n\t\t\tif pow2 > max2Power:\n\t\t\t\tmax2Power = pow2\n\t\treturn totOddRem + max2Power\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile any(nums):\n\t\t\tans += sum((n % 2 for n in nums))\n\t\t\tif any((n > 1 for n in nums)):\n\t\t\t\tans += 1\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(maxLmove, bitCount) = (0, 0)\n\t\tfor num in nums:\n\t\t\tif num == 0:\n\t\t\t\tcontinue\n\t\t\tLmove = 0\n\t\t\twhile num != 0:\n\t\t\t\tif num & 1:\n\t\t\t\t\tbitCount += 1\n\t\t\t\tnum = num >> 1\n\t\t\t\tif num != 0:\n\t\t\t\t\tLmove += 1\n\t\t\tmaxLmove = max(maxLmove, Lmove)\n\t\treturn maxLmove + bitCount\n", "class Solution:\n\n\tdef minOperations0(self, nums: List[int]) -> int:\n\t\tl = len(nums)\n\t\tans = 0\n\n\t\tdef turnEven():\n\t\t\tnonlocal ans\n\t\t\tfor i in range(l):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tans += 1\n\n\t\tdef countZero():\n\t\t\tcount = 0\n\t\t\tfor n in nums:\n\t\t\t\tif n == 0:\n\t\t\t\t\tcount += 1\n\t\t\treturn count\n\t\twhile True:\n\t\t\tturnEven()\n\t\t\tif countZero() == l:\n\t\t\t\treturn ans\n\t\t\tfor i in range(l):\n\t\t\t\tnums[i] //= 2\n\t\t\tans += 1\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tmaxLen = 1\n\t\tfor n in nums:\n\t\t\tbits = 0\n\t\t\twhile n > 0:\n\t\t\t\tres += n & 1\n\t\t\t\tbits += 1\n\t\t\t\tn >>= 1\n\t\t\tmaxLen = max(maxLen, bits)\n\t\treturn res + maxLen - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tmaxi = 0\n\t\tfor num in nums:\n\t\t\tres += 1 if num > 0 else 0\n\t\t\tdiv = 0\n\t\t\twhile num > 1:\n\t\t\t\tres += 1 if num % 2 else 0\n\t\t\t\tnum //= 2\n\t\t\t\tdiv += 1\n\t\t\tmaxi = max(div, maxi)\n\t\treturn res + maxi\n", "def val(n):\n\tc = 0\n\twhile n > 1:\n\t\tif n % 2 == 1:\n\t\t\tc += 1\n\t\t\tn -= 1\n\t\telse:\n\t\t\tn = n // 2\n\treturn c\n\ndef ma(n):\n\tc = 0\n\twhile n > 1:\n\t\tif n % 2 == 1:\n\t\t\tn -= 1\n\t\telse:\n\t\t\tn = n // 2\n\t\t\tc += 1\n\treturn c\n\nclass Solution:\n\n\tdef minOperations(self, n: List[int]) -> int:\n\t\tc = ma(max(n))\n\t\tfor i in range(len(n)):\n\t\t\tif n[i] > 0:\n\t\t\t\tc += val(n[i]) + 1\n\t\treturn c\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\thighest_bit = 0\n\t\taddone = 0\n\t\tfor num in nums:\n\t\t\ttmp = -1\n\t\t\twhile num > 0:\n\t\t\t\taddone += num & 1\n\t\t\t\tnum >>= 1\n\t\t\t\ttmp += 1\n\t\t\thighest_bit = max(highest_bit, tmp)\n\t\treturn highest_bit + addone\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif max(nums) == 0:\n\t\t\treturn 0\n\t\treturn sum(map(lambda x: bin(x).count('1'), nums)) + int(log2(max(nums)))\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top0 = 0\n\t\top1 = 0\n\t\tfor n in nums:\n\t\t\tl = 0\n\t\t\twhile n > 0:\n\t\t\t\tl += 1\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\top0 += 1\n\t\t\t\tn //= 2\n\t\t\top1 = max(op1, l - 1)\n\t\treturn op0 + op1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(two, one) = (0, 0)\n\t\tfor n in nums:\n\t\t\tmul = 0\n\t\t\twhile n:\n\t\t\t\tif n % 2:\n\t\t\t\t\tone += 1\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\tmul += 1\n\t\t\t\t\tn //= 2\n\t\t\ttwo = max(two, mul)\n\t\treturn one + two\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmx = 1\n\t\tops = 0\n\t\tfor nm in nums:\n\t\t\tbt = 0\n\t\t\twhile nm > 0:\n\t\t\t\tops += nm & 1\n\t\t\t\tbt += 1\n\t\t\t\tnm = nm >> 1\n\t\t\tmx = max(mx, bt)\n\t\treturn ops + mx - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef ops(num):\n\t\t\tplus = 0\n\t\t\tmult = 0\n\t\t\twhile num:\n\t\t\t\tif num % 2:\n\t\t\t\t\tplus += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\tnum //= 2\n\t\t\t\t\tmult += 1\n\t\t\treturn (plus, mult)\n\t\tplus = 0\n\t\tmult = 0\n\t\tfor num in nums:\n\t\t\t(plus_, mult_) = ops(num)\n\t\t\tplus += plus_\n\t\t\tmult = max(mult, mult_)\n\t\treturn plus + mult\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttotal = 0\n\t\tcurrentMax = 0\n\t\tfor n in nums:\n\t\t\tif n == 0:\n\t\t\t\tcontinue\n\t\t\ttotal += 1\n\t\t\tcount = 0\n\t\t\twhile n > 1:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tn -= 1\n\t\t\t\t\ttotal += 1\n\t\t\t\tn = n // 2\n\t\t\t\tcount += 1\n\t\t\tcurrentMax = max(count, currentMax)\n\t\treturn total + currentMax\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef calculate(num):\n\t\t\ttemp1 = 0\n\t\t\ttemp2 = 0\n\t\t\twhile num:\n\t\t\t\tif num % 2:\n\t\t\t\t\ttemp1 += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\ttemp2 += 1\n\t\t\t\t\tnum >>= 1\n\t\t\treturn (temp1, temp2)\n\t\t(ones, twos) = (0, 0)\n\t\tfor val in nums:\n\t\t\tif val:\n\t\t\t\t(a, b) = calculate(val)\n\t\t\t\tones += a\n\t\t\t\ttwos = max(twos, b)\n\t\tprint(ones)\n\t\treturn ones + twos\n", "class Solution:\n\n\tdef calc(self, num):\n\t\tm = 0\n\t\ta = 0\n\t\twhile num > 0:\n\t\t\tif num & 1:\n\t\t\t\ta += 1\n\t\t\t\tnum -= 1\n\t\t\telse:\n\t\t\t\tnum = num >> 1\n\t\t\t\tm += 1\n\t\treturn (a, m)\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tadds = 0\n\t\tmults = 0\n\t\tfor i in range(len(nums)):\n\t\t\t(a, m) = self.calc(nums[i])\n\t\t\tif mults < m:\n\t\t\t\tmults = m\n\t\t\tadds += a\n\t\treturn mults + adds\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcache = defaultdict(int)\n\t\tfor i in nums:\n\t\t\tfor (ind, j) in enumerate(bin(i)[2:][::-1]):\n\t\t\t\tif j == '1':\n\t\t\t\t\tcache[ind] += 1\n\t\treturn sum(cache.values()) + max(cache.keys())\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\ts = sum(nums)\n\t\twhile s:\n\t\t\todd_ct = len([0 for n in nums if n & 1])\n\t\t\top += odd_ct\n\t\t\ts -= odd_ct\n\t\t\tif s != 0:\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\t\t\top += 1\n\t\t\t\ts /= 2\n\t\treturn op\n", "from collections import Counter\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_doubles = 0\n\t\tincrements = 0\n\t\tcounts = Counter(nums)\n\t\tfor (n, c) in counts.items():\n\t\t\tif n == 0:\n\t\t\t\tcontinue\n\t\t\tdoubles = 0\n\t\t\twhile n:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tincrements += c\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\tdoubles += 1\n\t\t\t\t\tn //= 2\n\t\t\tmax_doubles = max(max_doubles, doubles)\n\t\treturn increments + max_doubles\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(div_arr, sub_arr) = ([], [])\n\t\tfor n in nums:\n\t\t\tdiv = 0\n\t\t\tsub = 0\n\t\t\twhile n:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tsub += 1\n\t\t\t\telse:\n\t\t\t\t\tn = n // 2\n\t\t\t\t\tdiv += 1\n\t\t\tsub_arr.append(sub)\n\t\t\tdiv_arr.append(div)\n\t\treturn max(div_arr) + sum(sub_arr)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile any((n > 0 for n in nums)):\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\tif all((n == 0 for n in nums)):\n\t\t\t\tbreak\n\t\t\tnums = [n // 2 for n in nums]\n\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef countBit(num):\n\t\t\t(count, highbit) = (0, 0)\n\t\t\twhile num > 0:\n\t\t\t\thighbit += 1\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tcount += 1\n\t\t\t\tnum //= 2\n\t\t\treturn (count, highbit)\n\t\tnums = sorted(nums)\n\t\tlast = {}\n\t\tsum = 0\n\t\tmaxDouble = 0\n\t\tfor num in nums:\n\t\t\tif num == 0:\n\t\t\t\tcontinue\n\t\t\telif num in last:\n\t\t\t\tsum += last[num]\n\t\t\telse:\n\t\t\t\t(count, highbit) = countBit(num)\n\t\t\t\tmaxDouble = max(maxDouble, highbit)\n\t\t\t\tsum += count\n\t\t\t\tlast = {num: count}\n\t\tprint(sum, maxDouble)\n\t\tif maxDouble == 0:\n\t\t\treturn 0\n\t\treturn sum + maxDouble - 1\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(ones, co, twos) = (0, 0, 0)\n\t\tfor xx in nums:\n\t\t\t(x, c) = (0, 0)\n\t\t\twhile xx > 1:\n\t\t\t\tco += xx & 1\n\t\t\t\txx //= 2\n\t\t\t\tc += 1\n\t\t\tx = int(floor(math.log(max(xx, 1), 2)))\n\t\t\ttwos = max(twos, x + c)\n\t\t\tones += max(xx - 2 ** x, 0)\n\t\t\tif xx >= 1:\n\t\t\t\tones += 1\n\t\treturn ones + twos + co\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tres = 0\n\t\twhile any((v > 0 for v in nums)):\n\t\t\tfor (i, v) in enumerate(nums):\n\t\t\t\tif v & 1:\n\t\t\t\t\tres += 1\n\t\t\t\tnums[i] >>= 1\n\t\t\tres += 1\n\t\treturn res - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmulti_max = 0\n\t\tanswer = 0\n\t\tfor num in nums:\n\t\t\tcur_multi = 0\n\t\t\twhile num:\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tanswer += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\tcur_multi += 1\n\t\t\t\t\tnum //= 2\n\t\t\tmulti_max = max(multi_max, cur_multi)\n\t\treturn answer + multi_max\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif not nums:\n\t\t\treturn 0\n\t\t(ans, nxt) = (0, [])\n\t\tfor num in nums:\n\t\t\tif num & 1:\n\t\t\t\tnum -= 1\n\t\t\t\tans += 1\n\t\t\tif num:\n\t\t\t\tnxt.append(num // 2)\n\t\tif nxt:\n\t\t\tans += 1\n\t\treturn ans + self.minOperations(nxt)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn_add = 0\n\t\tn_mul = 0\n\t\tfor n in nums:\n\t\t\tmul = 0\n\t\t\twhile n > 0:\n\t\t\t\tif n % 2:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tn_add += 1\n\t\t\t\telse:\n\t\t\t\t\tmul += 1\n\t\t\t\t\tn //= 2\n\t\t\tn_mul = max(n_mul, mul)\n\t\treturn n_add + n_mul\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tres = 0\n\t\tdouble = 0\n\t\tfor i in nums:\n\t\t\tcount = 0\n\t\t\twhile i:\n\t\t\t\tif i % 2 == 1:\n\t\t\t\t\ti -= 1\n\t\t\t\t\tres += 1\n\t\t\t\telse:\n\t\t\t\t\ti //= 2\n\t\t\t\t\tcount += 1\n\t\t\tdouble = max(double, count)\n\t\treturn res + double\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tones = 0\n\t\tmaxlen = 0\n\t\tbinlen = 0\n\t\tfor num in nums:\n\t\t\tbinlen = 0\n\t\t\twhile num != 0:\n\t\t\t\tif num % 2 != 0:\n\t\t\t\t\tones += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\tif num != 0:\n\t\t\t\t\tnum //= 2\n\t\t\t\t\tbinlen += 1\n\t\t\tmaxlen = max(maxlen, binlen)\n\t\treturn maxlen + ones\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tnum = max(nums)\n\t\tres = 0\n\t\tfor i in range(n):\n\t\t\tif nums[i] == 0:\n\t\t\t\tcontinue\n\t\t\tres += 1\n\t\t\tnum = nums[i]\n\t\t\twhile num > 1:\n\t\t\t\tres += num % 2\n\t\t\t\tnum //= 2\n\t\tc = 0\n\t\tnum = max(nums)\n\t\twhile num > 1:\n\t\t\tnum //= 2\n\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef calc(num):\n\t\t\ttmp = 1\n\t\t\tans = [0, 0]\n\t\t\tcount = 0\n\t\t\twhile tmp <= num:\n\t\t\t\tif tmp & num != 0:\n\t\t\t\t\tans[0] += 1\n\t\t\t\tcount += 1\n\t\t\t\ttmp <<= 1\n\t\t\tans[1] = count - 1\n\t\t\treturn ans\n\t\tresult = 0\n\t\ttt = 0\n\t\tfor num in nums:\n\t\t\tr = calc(num)\n\t\t\tresult += r[0]\n\t\t\ttt = max(tt, r[1])\n\t\tresult += tt\n\t\treturn result\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tmaxt = 0\n\t\tfor i in nums:\n\t\t\tif i == 0:\n\t\t\t\tcontinue\n\t\t\tt = 0\n\t\t\twhile i > 0:\n\t\t\t\tif i & 1:\n\t\t\t\t\ti -= 1\n\t\t\t\t\tans += 1\n\t\t\t\telse:\n\t\t\t\t\ti >>= 1\n\t\t\t\t\tt += 1\n\t\t\tmaxt = max(maxt, t)\n\t\tans += maxt\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = 0\n\t\tmax_len = 0\n\t\tfor num in nums:\n\t\t\tb = bin(num)\n\t\t\tresult += b.count('1')\n\t\t\tmax_len = max(max_len, len(b))\n\t\treturn result + max_len - 3\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tdoubles = 0\n\t\tincs = 0\n\t\tfor num in nums:\n\t\t\tnumDoubles = 0\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 == 0:\n\t\t\t\t\tnum //= 2\n\t\t\t\t\tnumDoubles += 1\n\t\t\t\telse:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\tincs += 1\n\t\t\tdoubles = max(doubles, numDoubles)\n\t\treturn doubles + incs\n", "class Solution:\n\n\tdef minOpsSingle(self, x):\n\t\tn_inc = 0\n\t\tn_db = 0\n\t\tassert x >= 0\n\t\twhile x > 0:\n\t\t\tif x % 2 == 0:\n\t\t\t\tx = x // 2\n\t\t\t\tn_db += 1\n\t\t\telse:\n\t\t\t\tx -= 1\n\t\t\t\tn_inc += 1\n\t\treturn (n_inc, n_db)\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttot_inc = 0\n\t\ttot_db = 0\n\t\tfor n in nums:\n\t\t\t(x, y) = self.minOpsSingle(n)\n\t\t\ttot_inc += x\n\t\t\ttot_db = max(tot_db, y)\n\t\treturn tot_inc + tot_db\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile not all((ele < 2 for ele in nums)):\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\t\tnums[i] //= 2\n\t\t\tcount += 1\n\t\tcount += sum((ele == 1 for ele in nums))\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmultiply = 0\n\t\tadd = 0\n\t\tfor num in nums:\n\t\t\tmask = 1\n\t\t\tfor i in range(32):\n\t\t\t\tif mask << i & num:\n\t\t\t\t\tmultiply = max(i, multiply)\n\t\t\t\t\tadd += 1\n\t\treturn multiply + add\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tans = 0\n\t\twhile True:\n\t\t\tzeros = 0\n\t\t\tans += 1\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tnums[i] = num // 2\n\t\t\t\tans += num % 2\n\t\t\t\tif not nums[i]:\n\t\t\t\t\tzeros += 1\n\t\t\tif zeros == n:\n\t\t\t\tbreak\n\t\treturn ans - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef calcOps(num):\n\t\t\tone = 0\n\t\t\ttwo = 0\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 == 0:\n\t\t\t\t\tnum //= 2\n\t\t\t\t\ttwo += 1\n\t\t\t\telse:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\tone += 1\n\t\t\treturn [one, two]\n\t\tone = 0\n\t\ttwo = 0\n\t\tfor x in nums:\n\t\t\tops = calcOps(x)\n\t\t\tone += ops[0]\n\t\t\ttwo = max(two, ops[1])\n\t\treturn one + two\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmove = 0\n\t\twhile max(nums) > 0:\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tmove += 1\n\t\t\t\tnums[i] = num // 2\n\t\t\tif max(nums) > 0:\n\t\t\t\tmove += 1\n\t\treturn move\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\twhile any((x != 0 for x in nums)):\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif x % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\tif sum(nums) == 0:\n\t\t\t\tbreak\n\t\t\tnums = [x // 2 for x in nums]\n\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef all_zeros(nums):\n\t\t\tfor num in nums:\n\t\t\t\tif num != 0:\n\t\t\t\t\treturn False\n\t\t\treturn True\n\n\t\tdef to_all_evens(nums):\n\t\t\tcnt = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tcnt += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\treturn cnt\n\t\top_cnt = 0\n\t\twhile not all_zeros(nums):\n\t\t\top_cnt += to_all_evens(nums)\n\t\t\tif not all_zeros(nums):\n\t\t\t\tnums = [x // 2 for x in nums]\n\t\t\t\top_cnt += 1\n\t\treturn op_cnt\n", "class Solution:\n\n\tdef minOperations(self, a: List[int]) -> int:\n\t\t(ans, max_len) = (0, 0)\n\t\tfor (i, x) in enumerate(a):\n\t\t\tb = bin(x)\n\t\t\tans += b.count('1')\n\t\t\tmax_len = max(max_len, len(b) - 2)\n\t\treturn ans + max_len - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tmax_len = 0\n\t\tfor x in nums:\n\t\t\tbit = 0\n\t\t\twhile x > 0:\n\t\t\t\tif x % 2 == 1:\n\t\t\t\t\tres += 1\n\t\t\t\tx >>= 1\n\t\t\t\tbit += 1\n\t\t\tmax_len = max(max_len, bit)\n\t\treturn res + max_len - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt = 0\n\t\t(max_val, max_index) = (-1, len(nums))\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] > max_val:\n\t\t\t\tmax_val = nums[i]\n\t\t\t\tmax_index = i\n\t\twhile max_val != 0:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcnt += 1\n\t\t\tmax_val = nums[max_index]\n\t\t\tif max_val == 0:\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tcnt += 1\n\t\t\tmax_val = nums[max_index]\n\t\treturn cnt\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt1 = 0\n\t\tmaxcnt0 = 0\n\t\tfor n in nums:\n\t\t\tcnt0 = 0\n\t\t\twhile n > 0:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tcnt1 += 1\n\t\t\t\telse:\n\t\t\t\t\tn //= 2\n\t\t\t\t\tcnt0 += 1\n\t\t\tmaxcnt0 = max(cnt0, maxcnt0)\n\t\treturn maxcnt0 + cnt1\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tarr = nums.copy()\n\t\tcount = result = 0\n\t\twhile any(arr):\n\t\t\tfor (i, n) in enumerate(arr):\n\t\t\t\tif n & 1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tarr[i] -= 1\n\t\t\tresult += count\n\t\t\tarr = [x >> 1 for x in arr]\n\t\t\tcount = 0\n\t\treturn result + int(math.log2(max(nums)))\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tc = 0\n\t\twhile True:\n\t\t\tc0 = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tc += 1\n\t\t\t\t\tnums[i] = (nums[i] - 1) // 2\n\t\t\t\telse:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tc0 += 1\n\t\t\tif c0 == len(nums):\n\t\t\t\treturn c\n\t\t\telse:\n\t\t\t\tc += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef iter_count(x):\n\t\t\tshift_count = sub_count = 0\n\t\t\twhile x > 0:\n\t\t\t\tif x & 1:\n\t\t\t\t\tx -= 1\n\t\t\t\t\tsub_count += 1\n\t\t\t\telse:\n\t\t\t\t\tx >>= 1\n\t\t\t\t\tshift_count += 1\n\t\t\treturn (shift_count, sub_count)\n\t\tmax_shift_count = 0\n\t\ttotal_subs = 0\n\t\tfor x in nums:\n\t\t\t(i, j) = iter_count(x)\n\t\t\tmax_shift_count = max(max_shift_count, i)\n\t\t\ttotal_subs += j\n\t\treturn max_shift_count + total_subs\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount_of_one_steps = 0\n\t\tcount_of_half_steps = 0\n\t\tfor i in nums:\n\t\t\tone_steps = 0\n\t\t\thalf_steps = 0\n\t\t\twhile i != 0:\n\t\t\t\tif i % 2 == 0:\n\t\t\t\t\thalf_steps += 1\n\t\t\t\t\ti //= 2\n\t\t\t\telse:\n\t\t\t\t\tone_steps += 1\n\t\t\t\t\ti -= 1\n\t\t\tcount_of_one_steps += one_steps\n\t\t\tcount_of_half_steps = max(count_of_half_steps, half_steps)\n\t\treturn count_of_one_steps + count_of_half_steps\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef countcall(x, c):\n\t\t\tc0 = 0\n\t\t\tfor i in range(len(x)):\n\t\t\t\tif x[i] % 2 == 1:\n\t\t\t\t\tc += 1\n\t\t\t\t\tx[i] = (x[i] - 1) // 2\n\t\t\t\telse:\n\t\t\t\t\tx[i] = x[i] // 2\n\t\t\t\tif x[i] == 0:\n\t\t\t\t\tc0 += 1\n\t\t\tif c0 == len(x):\n\t\t\t\treturn c\n\t\t\telse:\n\t\t\t\tc += 1\n\t\t\t\treturn countcall(x, c)\n\t\treturn countcall(nums, 0)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(x, y) = (0, 0)\n\t\tfor num in nums:\n\t\t\tnum = format(num, 'b')\n\t\t\tx += num.count('1')\n\t\t\ty = max(y, len(num) - 1)\n\t\treturn x + y\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef check(n):\n\t\t\tN_minus_one = 0\n\t\t\tN_div2 = 0\n\t\t\twhile n > 0:\n\t\t\t\tif n % 2 == 0:\n\t\t\t\t\tn = n // 2\n\t\t\t\t\tN_div2 += 1\n\t\t\t\telse:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tN_minus_one += 1\n\t\t\treturn (N_minus_one, N_div2)\n\t\tN = len(nums)\n\t\tminus_one = []\n\t\tdiv2 = []\n\t\tfor n in nums:\n\t\t\t(N_minus_one, N_div2) = check(n)\n\t\t\tminus_one.append(N_minus_one)\n\t\t\tdiv2.append(N_div2)\n\t\tres = sum(minus_one)\n\t\tres += max(div2)\n\t\tprint(minus_one)\n\t\tprint(div2)\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcost = 0\n\t\tmax_nb_op_1 = 0\n\t\tfor i in range(len(nums)):\n\t\t\tnb_op_0 = nb_op_1 = 0\n\t\t\tx = nums[i]\n\t\t\twhile x > 0:\n\t\t\t\tif x % 2 != 0:\n\t\t\t\t\tnb_op_0 += x % 2\n\t\t\t\t\tx -= x % 2\n\t\t\t\tif x > 0:\n\t\t\t\t\tnb_op_1 += 1\n\t\t\t\t\tx = x // 2\n\t\t\tcost += nb_op_0\n\t\t\tmax_nb_op_1 = max(max_nb_op_1, nb_op_1)\n\t\tcost += max_nb_op_1\n\t\treturn cost\n\n\tdef minOperations_dumb_solution(self, nums: List[int]) -> int:\n\t\tcost = 0\n\t\twhile True:\n\t\t\tall_zeros = True\n\t\t\tall_evens = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tall_zeros = False\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tcost += nums[i] % 2\n\t\t\t\t\tnums[i] = nums[i] - nums[i] % 2\n\t\t\t\t\tall_evens = False\n\t\t\tif all_zeros:\n\t\t\t\tbreak\n\t\t\twhile all_evens:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\t\tall_evens = False\n\t\t\t\tcost += 1\n\t\treturn cost\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tstep = 0\n\t\twhile True:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\t\tstep += 1\n\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tif sum(nums) == 0:\n\t\t\t\treturn step\n\t\t\tstep += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tones = 0\n\t\tdoubles = 0\n\t\twhile sum(nums) != 0:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tones += 1\n\t\t\tif sum(nums) != 0:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tdoubles += 1\n\t\treturn ones + doubles\n", "class Solution:\n\n\tdef getPow(self, n: int) -> Tuple[int, int]:\n\t\tif n == 0:\n\t\t\treturn (0, -1)\n\t\tif n == 1:\n\t\t\treturn (1, 0)\n\t\tinc = 0\n\t\tmul = 0\n\t\ti = n\n\t\twhile i != 0:\n\t\t\tif i % 2 == 1:\n\t\t\t\tinc += 1\n\t\t\t\ti = i - 1\n\t\t\telse:\n\t\t\t\ti = i // 2\n\t\t\t\tmul += 1\n\t\treturn (inc, mul)\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tpows = [self.getPow(n) for n in nums]\n\t\tnum_incs = 0\n\t\tnum_mults = 0\n\t\tmax_pow = 0\n\t\tfor i in range(0, len(nums)):\n\t\t\tif nums[i] == 0:\n\t\t\t\tcontinue\n\t\t\tif nums[i] == 1:\n\t\t\t\tnum_incs += 1\n\t\t\telse:\n\t\t\t\tinc = pows[i][0]\n\t\t\t\tpower = pows[i][1]\n\t\t\t\tnum_incs += inc\n\t\t\t\tif power > max_pow:\n\t\t\t\t\tmax_pow = power\n\t\tnum_incs += max_pow\n\t\treturn num_incs\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt = 0\n\t\tif self.check(nums):\n\t\t\treturn cnt\n\t\twhile not self.check(nums):\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tcnt += nums[i] % 2\n\t\t\tcnt += 1\n\t\t\tself.divide2(nums)\n\t\treturn cnt - 1\n\n\tdef check(self, nums):\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] != 0:\n\t\t\t\treturn False\n\t\treturn True\n\n\tdef divide2(self, nums):\n\t\tfor i in range(len(nums)):\n\t\t\tnums[i] //= 2\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef fun_call(num, mem):\n\t\t\tif not mem.get(num) is None:\n\t\t\t\treturn mem[num]\n\t\t\tadd = 0\n\t\t\tmul = 0\n\t\t\told_num = num\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 == 0:\n\t\t\t\t\tnum //= 2\n\t\t\t\t\tmul += 1\n\t\t\t\telse:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\tadd += 1\n\t\t\tmem[old_num] = (add, mul)\n\t\t\treturn mem[old_num]\n\t\tres = 0\n\t\tmul_max = 0\n\t\tmem = {0: (0, 0)}\n\t\tfor i in range(len(nums)):\n\t\t\t(add, mul) = fun_call(nums[i], mem)\n\t\t\tres += add\n\t\t\tmul_max = max(mul_max, mul)\n\t\tres += mul_max\n\t\treturn res\n", "class Solution:\n\n\tdef toZero(self, n):\n\t\textra = 0\n\t\tpwr2 = 0\n\t\twhile n > 0:\n\t\t\tif n % 2:\n\t\t\t\tn -= 1\n\t\t\t\textra += 1\n\t\t\telse:\n\t\t\t\tn = n / 2\n\t\t\t\tpwr2 += 1\n\t\treturn [extra, pwr2]\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxPwr2 = 0\n\t\textras = 0\n\t\tfor n in nums:\n\t\t\ta = self.toZero(n)\n\t\t\tmaxPwr2 = max(maxPwr2, a[1])\n\t\t\textras += a[0]\n\t\treturn extras + maxPwr2\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tmask = 2 ** 32 - 2\n\t\tfor _ in range(32):\n\t\t\tend = True\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tres += x & 1\n\t\t\t\tnums[i] >>= 1\n\t\t\t\tif nums[i]:\n\t\t\t\t\tend = False\n\t\t\tif end:\n\t\t\t\tbreak\n\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 != 0 and nums[i] > 0:\n\t\t\t\tcount += 1\n\t\t\t\tnums[i] -= 1\n\t\tif nums == [0] * len(nums):\n\t\t\treturn count\n\t\tnums = [i // 2 for i in nums]\n\t\treturn count + self.minOperations(nums) + 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile True:\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\tif sum(nums) == 0:\n\t\t\t\treturn count\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\tcount += 1\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tplus_one = times_two = 0\n\t\tfor (idx, num) in enumerate(nums):\n\t\t\ttwo = 0\n\t\t\twhile num:\n\t\t\t\tif num == 1:\n\t\t\t\t\tplus_one += 1\n\t\t\t\t\tbreak\n\t\t\t\tif num % 2:\n\t\t\t\t\tplus_one += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\tnum = num // 2\n\t\t\t\ttwo += 1\n\t\t\ttimes_two = max(times_two, two)\n\t\treturn plus_one + times_two\n", "class Solution:\n\n\tdef minOperations(self, nums) -> int:\n\t\tres = 0\n\t\tN = len(nums)\n\t\twhile True:\n\t\t\tfor (i, v) in enumerate(nums):\n\t\t\t\tif v & 1:\n\t\t\t\t\tres += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tif nums == [0] * N:\n\t\t\t\treturn res\n\t\t\tfor i in range(N):\n\t\t\t\tnums[i] //= 2\n\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(moves, ndone) = (0, len(nums) - nums.count(0))\n\t\twhile ndone:\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tmoves += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tndone -= 1\n\t\t\tif ndone:\n\t\t\t\tnums = [num // 2 for num in nums]\n\t\t\t\tmoves += 1\n\t\treturn moves\n", "def get_num_ops(num):\n\tassert num >= 0\n\t(d_ops, s_ops) = (0, 0)\n\twhile num != 0:\n\t\tif num % 2 == 1:\n\t\t\tnum = num - 1\n\t\t\ts_ops += 1\n\t\telse:\n\t\t\tnum = num // 2\n\t\t\td_ops += 1\n\treturn (d_ops, s_ops)\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnum_ops = 0\n\t\tdoubling_ops = []\n\t\tfor num in nums:\n\t\t\t(d, s) = get_num_ops(num)\n\t\t\tdoubling_ops.append(d)\n\t\t\tnum_ops += d + s\n\t\t\tprint(num_ops)\n\t\tdoubling_ops = sorted(doubling_ops)\n\t\tchange = [doubling_ops[0]]\n\t\tfor i in range(1, len(doubling_ops)):\n\t\t\tchange.append(doubling_ops[i] - doubling_ops[i - 1])\n\t\tfor (i, c) in enumerate(change):\n\t\t\tnum_ops = num_ops - c * (len(change) - i - 1)\n\t\treturn num_ops\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tmaxi = 0\n\t\tfor j in nums:\n\t\t\te = 0\n\t\t\tif j == 0:\n\t\t\t\tcontinue\n\t\t\tif j == 1:\n\t\t\t\tcount = count + 1\n\t\t\tif j > 1:\n\t\t\t\twhile j:\n\t\t\t\t\tif j % 2 == 0:\n\t\t\t\t\t\te = e + 1\n\t\t\t\t\t\tj = j // 2\n\t\t\t\t\telse:\n\t\t\t\t\t\tj = j - 1\n\t\t\t\t\t\tcount = count + 1\n\t\t\tif e > maxi:\n\t\t\t\tmaxi = e\n\t\tcount = count + maxi\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef count(n):\n\t\t\ta = b = 0\n\t\t\twhile n:\n\t\t\t\tif n & 1:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tb += 1\n\t\t\t\telse:\n\t\t\t\t\tn >>= 1\n\t\t\t\t\ta += 1\n\t\t\treturn (a, b)\n\t\tmaxA = sumB = 0\n\t\tfor n in nums:\n\t\t\t(a, b) = count(n)\n\t\t\tmaxA = max(maxA, a)\n\t\t\tsumB += b\n\t\treturn maxA + sumB\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnumber_of_moves = 0\n\t\twhile True:\n\t\t\tfor (pos, num) in enumerate(nums):\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tnums[pos] -= 1\n\t\t\t\t\tnumber_of_moves += 1\n\t\t\tif not any(nums):\n\t\t\t\tbreak\n\t\t\tnums = list([x // 2 for x in nums])\n\t\t\tnumber_of_moves += 1\n\t\treturn number_of_moves\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\tsum1 = sum(nums)\n\t\twhile sum1 != 0:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tsum1 -= 1\n\t\t\t\t\top += 1\n\t\t\tif sum1 == 0:\n\t\t\t\treturn op\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\top += 1\n\t\t\tsum1 /= 2\n\t\treturn op\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\td = {}\n\t\todd = 0\n\t\tmx_even = 0\n\t\tfor (i, val) in enumerate(nums):\n\t\t\teven = 0\n\t\t\twhile val:\n\t\t\t\tif val % 2 == 0:\n\t\t\t\t\twhile val > 0 and val % 2 == 0:\n\t\t\t\t\t\tval = val // 2\n\t\t\t\t\t\teven += 1\n\t\t\t\telse:\n\t\t\t\t\tval -= 1\n\t\t\t\t\todd += 1\n\t\t\tmx_even = max(even, mx_even)\n\t\treturn odd + mx_even\n", "from math import log\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tvposes = set(range(len(nums)))\n\t\twhile vposes:\n\t\t\trm = set()\n\t\t\tfor i in vposes:\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\tif not nums[i]:\n\t\t\t\t\trm.add(i)\n\t\t\tvposes.symmetric_difference_update(rm)\n\t\t\tchg = False\n\t\t\tfor i in vposes:\n\t\t\t\tchg = True\n\t\t\t\tnums[i] //= 2\n\t\t\tres += chg\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\tmax_div = 0\n\t\tfor n in nums:\n\t\t\tdivs = 0\n\t\t\twhile n > 0:\n\t\t\t\tif n % 2:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tops += 1\n\t\t\t\telse:\n\t\t\t\t\tn /= 2\n\t\t\t\t\tdivs += 1\n\t\t\tmax_div = max(max_div, divs)\n\t\treturn ops + max_div\n", "class Solution:\n\n\tdef minOperations(self, a: List[int]) -> int:\n\t\tans = 0\n\t\tzero_cnt = 0\n\t\twhile zero_cnt < len(a):\n\t\t\tzero_cnt = 0\n\t\t\tfor (i, x) in enumerate(a):\n\t\t\t\tif x % 2 == 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\ta[i] = (x - 1) // 2\n\t\t\t\telse:\n\t\t\t\t\ta[i] = x // 2\n\t\t\t\tzero_cnt += a[i] == 0\n\t\t\tans += zero_cnt < len(a)\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tsteps = 0\n\t\twhile True:\n\t\t\tfor idx in range(0, len(nums)):\n\t\t\t\tif nums[idx] % 2 == 1:\n\t\t\t\t\tnums[idx] -= 1\n\t\t\t\t\tsteps += 1\n\t\t\tif sum(nums) == 0:\n\t\t\t\tbreak\n\t\t\tnums = [int(x / 2) for x in nums]\n\t\t\tsteps += 1\n\t\treturn steps\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tn = len(nums)\n\t\tnot_zero = set(list(range(n)))\n\t\twhile True:\n\t\t\tif len(not_zero) == 0:\n\t\t\t\treturn ans\n\t\t\tzeros = []\n\t\t\tfor i in not_zero:\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tans += 1\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tzeros.append(i)\n\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tfor j in zeros:\n\t\t\t\tnot_zero.remove(j)\n\t\t\tif len(not_zero) > 0:\n\t\t\t\tans += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef get_add_mul_times(num: int):\n\t\t\t(a, b) = (0, 0)\n\t\t\twhile num > 0:\n\t\t\t\tif num >> 1 << 1 != num:\n\t\t\t\t\ta += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\tb += 1\n\t\t\t\t\tnum //= 2\n\t\t\treturn (a, b)\n\t\tN = len(nums)\n\t\t(add, mul) = ([0] * N, [0] * N)\n\t\tfor ii in range(N):\n\t\t\t(a, b) = get_add_mul_times(nums[ii])\n\t\t\tadd[ii] = a\n\t\t\tmul[ii] = b\n\t\treturn max(mul) + sum(add)\n", "import numpy as np\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tif not any(nums):\n\t\t\treturn count\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 != 0:\n\t\t\t\tnums[i] -= 1\n\t\t\t\tcount += 1\n\t\tif any(nums):\n\t\t\tcount += 1\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] = nums[i] // 2\n\t\treturn count + self.minOperations(nums)\n", "bin = '{:0b}'.format\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxBitLen = 0\n\t\tbitCount = 0\n\t\tfor num in nums:\n\t\t\tb = bin(num)\n\t\t\tmaxBitLen = max(maxBitLen, len(b))\n\t\t\tbitCount += b.count('1')\n\t\treturn maxBitLen + bitCount - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\t@lru_cache(None)\n\t\tdef helper(num):\n\t\t\tif num < 2:\n\t\t\t\treturn (num, 0)\n\t\t\t(a, b) = helper(num // 2)\n\t\t\treturn (a + num % 2, b + 1)\n\t\ta = b = 0\n\t\tfor num in nums:\n\t\t\t(tmpa, tmpb) = helper(num)\n\t\t\ta += tmpa\n\t\t\tb = max(b, tmpb)\n\t\treturn a + b\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef helper(num):\n\t\t\tif num in self.dic:\n\t\t\t\treturn self.dic[num]\n\t\t\tn = num\n\t\t\t(count, even) = (0, 0)\n\t\t\twhile n != 0:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\tn //= 2\n\t\t\t\t\teven += 1\n\t\t\t\tcount += 1\n\t\t\tself.dic[num] = (count, even)\n\t\t\treturn (count, even)\n\t\t(ans, maxb, self.dic) = (0, 0, {})\n\t\tfor num in nums:\n\t\t\t(a, b) = helper(num)\n\t\t\tans += a - b\n\t\t\tmaxb = max(maxb, b)\n\t\treturn ans + maxb\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tsteps = 0\n\t\t(maxIdx, maxNum) = (None, -math.inf)\n\t\tfor (idx, num) in enumerate(nums):\n\t\t\tif num > maxNum:\n\t\t\t\tmaxNum = num\n\t\t\t\tmaxIdx = idx\n\t\t(nums[maxIdx], nums[-1]) = (nums[-1], nums[maxIdx])\n\n\t\tdef divideBy2(nums):\n\t\t\tnums = [num // 2 for num in nums]\n\t\t\treturn nums\n\t\twhile nums[-1] > 0:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tsteps += 1\n\t\t\tif nums[-1] == 0:\n\t\t\t\treturn steps\n\t\t\tnums = divideBy2(nums)\n\t\t\tsteps += 1\n\t\treturn steps\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tadd = 0\n\t\tdouble = 0\n\t\tans = 0\n\t\tfor i in range(len(nums)):\n\t\t\tx = nums[i]\n\t\t\tif x == 0:\n\t\t\t\tcontinue\n\t\t\tadd += 1\n\t\t\tcurr = 0\n\t\t\twhile x != 1:\n\t\t\t\tif x % 2 != 0:\n\t\t\t\t\tx -= 1\n\t\t\t\t\tadd += 1\n\t\t\t\twhile x % 2 != 1:\n\t\t\t\t\tx /= 2\n\t\t\t\t\tcurr += 1\n\t\t\tdouble = max(double, curr)\n\t\tans = double + add\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top_count = 0\n\t\twhile not all([v == 0 for v in nums]):\n\t\t\tfor i in range(len(nums)):\n\t\t\t\todd = nums[i] % 2\n\t\t\t\tif odd:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\top_count += 1\n\t\t\t\tnums[i] //= 2\n\t\t\top_count += 1\n\t\treturn max(0, op_count - 1)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tall_zero = False\n\t\twhile not all_zero:\n\t\t\tall_zero = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\tnums[i] //= 2\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tall_zero = False\n\t\t\tif not all_zero:\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\t_max = 0\n\t\tfor i in nums:\n\t\t\tbit = 0\n\t\t\twhile i > 0:\n\t\t\t\tres += i & 1\n\t\t\t\ti >>= 1\n\t\t\t\tbit += 1\n\t\t\t_max = max(bit, _max)\n\t\treturn res + _max - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tmax_len = 0\n\t\tfor num in nums:\n\t\t\tbits = 0\n\t\t\twhile num > 0:\n\t\t\t\tres += num % 2\n\t\t\t\tnum >>= 1\n\t\t\t\tbits += 1\n\t\t\tmax_len = max(bits - 1, max_len)\n\t\treturn res + max_len\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tn = len(nums)\n\t\twhile 1:\n\t\t\tall0 = True\n\t\t\thas_div = False\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tall0 = False\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tres += 1\n\t\t\t\t\tif nums[i] > 1:\n\t\t\t\t\t\thas_div = True\n\t\t\t\t\tnums[i] = (nums[i] - 1) // 2\n\t\t\t\telse:\n\t\t\t\t\thas_div = True\n\t\t\t\t\tnums[i] //= 2\n\t\t\tif all0:\n\t\t\t\tbreak\n\t\t\tif has_div:\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile True:\n\t\t\tZero = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\t\tif nums[i]:\n\t\t\t\t\tZero = False\n\t\t\tif Zero:\n\t\t\t\treturn count\n\t\t\tcount += 1\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] >>= 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tcheck = 0\n\t\tif not nums:\n\t\t\treturn 0\n\t\twhile check != len(nums):\n\t\t\t(x, check, nums) = self.odd(nums)\n\t\t\tcount += x\n\t\t\tif check == len(nums):\n\t\t\t\treturn count\n\t\t\tnums = self.div(nums)\n\t\t\tcount += 1\n\n\tdef div(self, nums):\n\t\tfor i in range(len(nums)):\n\t\t\tnums[i] = nums[i] // 2\n\t\treturn nums\n\n\tdef odd(self, nums):\n\t\ta = 0\n\t\tb = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] & 1 == 1:\n\t\t\t\ta += 1\n\t\t\t\tnums[i] -= 1\n\t\t\tif nums[i] == 0:\n\t\t\t\tb += 1\n\t\treturn (a, b, nums)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxDivideCount = 0\n\t\tminusCount = 0\n\t\tfor num in nums:\n\t\t\tdivideCount = 0\n\t\t\twhile num != 0:\n\t\t\t\tif num % 2 == 0:\n\t\t\t\t\tnum //= 2\n\t\t\t\t\tdivideCount += 1\n\t\t\t\telse:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\tminusCount += 1\n\t\t\tmaxDivideCount = max(divideCount, maxDivideCount)\n\t\treturn maxDivideCount + minusCount\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\toneCnt = 0\n\t\tpwrCnt = 0\n\t\tfor num in nums:\n\t\t\tif num == 0:\n\t\t\t\tcontinue\n\t\t\texp = 0\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 == 0:\n\t\t\t\t\tnum /= 2\n\t\t\t\t\texp += 1\n\t\t\t\telse:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\toneCnt += 1\n\t\t\tpwrCnt = max(pwrCnt, exp)\n\t\treturn oneCnt + pwrCnt\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif sum(nums) == 0:\n\t\t\treturn 0\n\t\tsteps = 0\n\t\tn_zeros = 0\n\t\tfor (i, num) in enumerate(nums):\n\t\t\tif num % 2 != 0:\n\t\t\t\tnums[i] -= 1\n\t\t\t\tsteps += 1\n\t\t\tif nums[i] == 0:\n\t\t\t\tn_zeros += 1\n\t\t\tnums[i] = nums[i] // 2\n\t\tif n_zeros != len(nums):\n\t\t\tsteps += 1\n\t\treturn steps + self.minOperations(nums)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile any(nums):\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif x % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tans += 1\n\t\t\tif any(nums):\n\t\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_dev = 0\n\t\tsteps = 0\n\t\tfor i in nums:\n\t\t\tdev = 0\n\t\t\twhile i != 0:\n\t\t\t\tif i % 2 == 0:\n\t\t\t\t\ti = i / 2\n\t\t\t\t\tdev = dev + 1\n\t\t\t\telse:\n\t\t\t\t\ti = i - 1\n\t\t\t\t\tsteps = steps + 1\n\t\t\tif dev > max_dev:\n\t\t\t\tmax_dev = dev\n\t\treturn steps + max_dev\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tt = 0\n\t\tfor ele in nums:\n\t\t\tele = str(bin(ele))[2:]\n\t\t\tres += ele.count('1')\n\t\t\tt = max(t, len(ele) - 1)\n\t\treturn res + t\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tone = 0\n\t\ttwo_req = 0\n\t\tfor i in nums:\n\t\t\ttwo = 0\n\t\t\ti_copy = i\n\t\t\twhile i_copy > 0:\n\t\t\t\tif i_copy % 2 == 0:\n\t\t\t\t\ti_copy = i_copy // 2\n\t\t\t\t\ttwo += 1\n\t\t\t\telse:\n\t\t\t\t\ti_copy -= 1\n\t\t\t\t\tone += 1\n\t\t\ttwo_req = max(two_req, two)\n\t\tres = two_req + one\n\t\treturn res\n", "from math import log\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt = int(log(max(nums)) / log(2))\n\t\tfor n in nums:\n\t\t\twhile n > 0:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tn = n // 2\n\t\treturn cnt\n", "from functools import lru_cache\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tdivideByTwos = 0\n\t\tdecrements = 0\n\t\tfor num in nums:\n\t\t\tif num == 0:\n\t\t\t\tcontinue\n\t\t\t(divides, dec) = self.reductions(num)\n\t\t\tdivideByTwos = max(divideByTwos, divides)\n\t\t\tdecrements += dec\n\t\treturn divideByTwos + decrements\n\n\t@lru_cache(maxsize=None)\n\tdef reductions(self, num: int) -> (int, int):\n\t\tdecrements = 0\n\t\tdivides = 0\n\t\twhile num > 1:\n\t\t\tif num % 2 == 0:\n\t\t\t\tnum /= 2\n\t\t\t\tdivides += 1\n\t\t\telse:\n\t\t\t\tnum -= 1\n\t\t\t\tdecrements += 1\n\t\treturn (divides, decrements + 1)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\twhile not self.is_end(nums):\n\t\t\tops += self.perform_decrement(nums)\n\t\t\tif self.is_end(nums):\n\t\t\t\treturn ops\n\t\t\tops += self.perform_division(nums)\n\t\treturn ops\n\n\tdef is_end(self, nums):\n\t\treturn all((i == 0 for i in nums))\n\n\tdef perform_decrement(self, nums):\n\t\tops = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 == 1:\n\t\t\t\tnums[i] -= 1\n\t\t\t\tops += 1\n\t\treturn ops\n\n\tdef perform_division(self, nums):\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] != 0:\n\t\t\t\tnums[i] //= 2\n\t\treturn 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\t@lru_cache(None)\n\t\tdef get(n):\n\t\t\tadd = 0\n\t\t\tmul = 0\n\t\t\twhile n:\n\t\t\t\tif n & 1:\n\t\t\t\t\tadd += 1\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\tmul += 1\n\t\t\t\t\tn = n >> 1\n\t\t\treturn (add, mul)\n\t\tcadd = 0\n\t\tmmul = 0\n\t\tfor n in nums:\n\t\t\t(add, mul) = get(n)\n\t\t\tcadd += add\n\t\t\tmmul = max(mul, mmul)\n\t\treturn cadd + mmul\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tN = len(nums)\n\t\tansr = 0\n\t\twhile any(nums):\n\t\t\tdivideByTwo = False\n\t\t\tfor i in range(N):\n\t\t\t\tif nums[i] == 1:\n\t\t\t\t\tansr += 1\n\t\t\t\t\tnums[i] = 0\n\t\t\t\telif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\telse:\n\t\t\t\t\tdivideByTwo = True\n\t\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\t\tansr += 1\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tif divideByTwo:\n\t\t\t\tansr += 1\n\t\treturn ansr\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tn = len(nums)\n\t\twhile True:\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tstop = True\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\t\tstop = False\n\t\t\tif stop:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_divide = 0\n\t\tres = 0\n\t\tfor num in nums:\n\t\t\tcnt_divide = 0\n\t\t\twhile num:\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tres += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\tnum //= 2\n\t\t\t\t\tcnt_divide += 1\n\t\t\tmax_divide = max(max_divide, cnt_divide)\n\t\treturn res + max_divide\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tnums.sort()\n\t\twhile nums[-1] != 0:\n\t\t\tif nums[-1] >= 2:\n\t\t\t\tans += 1\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tans += num % 2\n\t\t\t\tnums[i] = num // 2\n\t\treturn ans\n", "import math\n\nclass Solution:\n\n\tdef rec(self, nums):\n\t\tif not nums:\n\t\t\treturn 0\n\t\tif len(nums) == 1:\n\t\t\tif nums[0] <= 2:\n\t\t\t\treturn nums[0]\n\t\t\tif nums[0] % 2 == 0:\n\t\t\t\tnums[0] = nums[0] // 2\n\t\t\t\treturn 1 + self.rec(nums)\n\t\t\telse:\n\t\t\t\tnums[0] = (nums[0] - 1) // 2\n\t\t\t\treturn 2 + self.rec(nums)\n\t\top = 0\n\t\tnew = []\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] != 0:\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\top += 1\n\t\t\t\t\tif nums[i] != 0:\n\t\t\t\t\t\tnew.append(nums[i] // 2)\n\t\t\t\telse:\n\t\t\t\t\tnew.append(nums[i] // 2)\n\t\tif len(new) > 0:\n\t\t\top += 1\n\t\treturn op + self.rec(new)\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\treturn self.rec(nums)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tN = len(nums)\n\t\tres = 0\n\t\twhile sum(nums) != 0:\n\t\t\tall_even = True\n\t\t\tfor i in range(N):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tall_even = False\n\t\t\t\t\tres += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tif all_even:\n\t\t\t\tres += 1\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\treturn res\n", "def ones(x):\n\treturn 0 if x == 0 else 1 + ones(x & x - 1)\n\ndef twos(x):\n\tcc = 0\n\twhile x > 1:\n\t\tx //= 2\n\t\tcc += 1\n\treturn cc\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\to = 0\n\t\tt = 0\n\t\tfor x in nums:\n\t\t\to += ones(x)\n\t\t\tt = max(t, twos(x))\n\t\treturn o + t\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tadd_count = 0\n\t\tmut_count = 0\n\n\t\tdef get_add_mut_count(n):\n\t\t\tadd = mut = 0\n\t\t\twhile n:\n\t\t\t\tif n % 2:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tadd += 1\n\t\t\t\telse:\n\t\t\t\t\tn /= 2\n\t\t\t\t\tmut += 1\n\t\t\treturn (add, mut)\n\t\tfor n in nums:\n\t\t\t(a, m) = get_add_mut_count(n)\n\t\t\tadd_count += a\n\t\t\tmut_count = max(mut_count, m)\n\t\treturn add_count + mut_count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile True:\n\t\t\tzeros = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 0:\n\t\t\t\t\tcontinue\n\t\t\t\telse:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\tfor j in range(len(nums)):\n\t\t\t\tif nums[j] == 0:\n\t\t\t\t\tzeros += 1\n\t\t\t\tnums[j] = nums[j] // 2\n\t\t\tif zeros == len(nums):\n\t\t\t\treturn count\n\t\t\tcount += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnums.sort()\n\t\tnums = nums[::-1]\n\t\tops = 0\n\t\tn = len(nums)\n\t\twhile nums:\n\t\t\twhile nums[-1] == 0:\n\t\t\t\tnums.pop()\n\t\t\t\tif not nums:\n\t\t\t\t\tbreak\n\t\t\t\tn -= 1\n\t\t\tif not nums:\n\t\t\t\tbreak\n\t\t\toc = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\toc = 1\n\t\t\t\t\tbreak\n\t\t\tif oc == 1:\n\t\t\t\tfor i in range(n):\n\t\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\t\tops += 1\n\t\t\t\t\t\tnums[i] -= 1\n\t\t\telse:\n\t\t\t\tops += 1\n\t\t\t\tfor i in range(n):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tvalid = {0: 0}\n\t\tfor i in range(31):\n\t\t\tvalid[2 ** i] = i\n\t\tans = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] > 0:\n\t\t\t\tans += 1\n\t\tmax_val = float('-inf')\n\t\tneed_step = [0] * len(nums)\n\t\tmax_multiply_step = 0\n\t\tfor i in range(len(nums)):\n\t\t\t(one_step, multiply_step) = (0, 0)\n\t\t\twhile nums[i] not in valid:\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tone_step += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\telse:\n\t\t\t\t\tmultiply_step += 1\n\t\t\t\t\tnums[i] //= 2\n\t\t\tmax_multiply_step = max(max_multiply_step, multiply_step + valid[nums[i]])\n\t\t\tans += one_step\n\t\tans += max_multiply_step\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tif len(nums) == 1:\n\t\t\tv = nums[0]\n\t\t\twhile v:\n\t\t\t\tif v % 2:\n\t\t\t\t\tans += 1\n\t\t\t\t\tv -= 1\n\t\t\t\tif v:\n\t\t\t\t\tv //= 2\n\t\t\t\t\tans += 1\n\t\t\treturn ans\n\t\tc = collections.Counter()\n\t\tfor (i, v) in enumerate(nums):\n\t\t\tif v % 2:\n\t\t\t\tnums[i] -= 1\n\t\t\t\tans += 1\n\t\t\tc[nums[i]] += 1\n\t\ttwo = 0\n\t\tfor v in sorted(c.keys()):\n\t\t\ttemp = 0\n\t\t\tt = 0\n\t\t\tu = v\n\t\t\twhile v:\n\t\t\t\tif v % 2:\n\t\t\t\t\tt += 1\n\t\t\t\t\tv -= 1\n\t\t\t\tif v:\n\t\t\t\t\tv //= 2\n\t\t\t\t\ttemp += 1\n\t\t\tans += t * c[u] + (temp - two)\n\t\t\ttwo += temp - two\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tzeroIndexes = set()\n\t\tresult = 0\n\t\tisEven = False\n\t\twhile len(zeroIndexes) != len(nums):\n\t\t\tif isEven:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] >>= 1\n\t\t\t\tresult += 1\n\t\t\t\tisEven = False\n\t\t\telse:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tif i not in zeroIndexes:\n\t\t\t\t\t\tif nums[i] & 1:\n\t\t\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\t\t\tresult += 1\n\t\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\t\tzeroIndexes.add(i)\n\t\t\t\tisEven = True\n\t\treturn result\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\twhile True:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tres += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tnumZeros = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tnumZeros += 1\n\t\t\tif numZeros == len(nums):\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\tres += 1\n\t\treturn res\n", "from collections import deque\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tstep = 0\n\t\twhile sum(nums):\n\t\t\tfor (i, val) in enumerate(nums):\n\t\t\t\tif val % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tstep += 1\n\t\t\tif sum(nums):\n\t\t\t\tstep += 1\n\t\t\t\tfor (i, val) in enumerate(nums):\n\t\t\t\t\tif val:\n\t\t\t\t\t\tnums[i] /= 2\n\t\treturn step\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile True:\n\t\t\tcount = 0\n\t\t\tflag = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\tflag = 1\n\t\t\tans += count\n\t\t\tif flag:\n\t\t\t\tans += 1\n\t\t\tcount = 0\n\t\t\tif nums.count(0) == len(nums):\n\t\t\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcounter = 0\n\t\twhile 1:\n\t\t\ttemp_counter = 0\n\t\t\tbigger_than_zero = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\ttemp_counter += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tbigger_than_zero += 1\n\t\t\tcounter += temp_counter\n\t\t\tif bigger_than_zero == 0:\n\t\t\t\treturn counter\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\tcounter += 1\n\t\treturn counter\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnums.sort(reverse=True)\n\t\tstep = 0\n\t\twhile any((n > 0 for n in nums)):\n\t\t\tif all((n % 2 == 0 for n in nums)):\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\t\t\tstep += 1\n\t\t\telse:\n\t\t\t\tremain_idx = []\n\t\t\t\tfor (i, v) in enumerate(nums):\n\t\t\t\t\tif v % 2 == 1:\n\t\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\t\t\tstep += 1\n\t\treturn step\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tm = 0\n\t\tf = 0\n\t\tfor x in nums:\n\t\t\tif x == 0:\n\t\t\t\tcontinue\n\t\t\tc = 0\n\t\t\tmm = 0\n\t\t\tbaz = x\n\t\t\twhile x > 1:\n\t\t\t\tif x % 2 == 0:\n\t\t\t\t\tx = x // 2\n\t\t\t\t\tmm += 1\n\t\t\t\telse:\n\t\t\t\t\tx -= 1\n\t\t\t\t\tc += 1\n\t\t\tprint((baz, c))\n\t\t\tf += 1 + c\n\t\t\tm = max(m, mm)\n\t\t\tprint(m)\n\t\tf += m\n\t\treturn f\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tret = 0\n\t\twhile nums.count(0) != len(nums):\n\t\t\tfor i in range(0, len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\t\tret = ret + 1\n\t\t\tnums[:] = [i / 2 for i in nums]\n\t\t\tret = ret + 1\n\t\treturn 0 if ret == 0 else ret - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile not all((n == 0 for n in nums)):\n\t\t\tdiv = 0\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n & 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\tn -= 1\n\t\t\t\tif n > 0:\n\t\t\t\t\tdiv = 1\n\t\t\t\t\tn //= 2\n\t\t\t\tnums[i] = n\n\t\t\tans += div\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef dfs(n):\n\t\t\tif sum(nums) == 0:\n\t\t\t\treturn n\n\t\t\tsubs = 0\n\t\t\tzeros = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tsubs += 1\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tzeros += 1\n\t\t\t\tnums[i] /= 2\n\t\t\tif zeros == len(nums):\n\t\t\t\treturn subs + n\n\t\t\treturn dfs(1 + subs + n)\n\t\treturn dfs(0)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef count(num):\n\t\t\tdiv = 0\n\t\t\tminus = 0\n\t\t\twhile num:\n\t\t\t\tif num % 2 == 0:\n\t\t\t\t\tnum = num // 2\n\t\t\t\t\tdiv += 1\n\t\t\t\telse:\n\t\t\t\t\tnum = num - 1\n\t\t\t\t\tminus += 1\n\t\t\treturn (div, minus)\n\t\tm = []\n\t\td = []\n\t\tfor i in nums:\n\t\t\t(div, minus) = count(i)\n\t\t\td.append(div)\n\t\t\tm.append(minus)\n\t\treturn max(d) + sum(m)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tans = 0\n\t\tm = 0\n\n\t\tdef get(val):\n\t\t\tret = 0\n\t\t\tgive = 0\n\t\t\twhile val != 0:\n\t\t\t\tif val & 1:\n\t\t\t\t\tval -= 1\n\t\t\t\t\tret += 1\n\t\t\t\telse:\n\t\t\t\t\tval = val // 2\n\t\t\t\t\tgive += 1\n\t\t\treturn (ret, give)\n\t\tfor i in range(n):\n\t\t\tif nums[i] == 0:\n\t\t\t\tcontinue\n\t\t\t(val, mult) = get(nums[i])\n\t\t\tm = max(m, mult)\n\t\t\tans += val\n\t\tans += m\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif nums == [0]:\n\t\t\treturn 0\n\t\tcopy = list(nums)\n\t\tans = 0\n\t\twhile any([el != 0 for el in copy]):\n\t\t\tnumOdd = 0\n\t\t\tfor i in range(len(copy)):\n\t\t\t\tif copy[i] % 2 != 0:\n\t\t\t\t\tnumOdd += 1\n\t\t\t\t\tcopy[i] -= 1\n\t\t\tfor i in range(len(copy)):\n\t\t\t\tcopy[i] /= 2\n\t\t\tans += numOdd + 1\n\t\treturn ans - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = m = 0\n\t\tfor x in nums:\n\t\t\ts = bin(x)[2:]\n\t\t\tm = max(len(s) - 1, m)\n\t\t\tn += len(s.replace('0', ''))\n\t\treturn m + n\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = max_mult = 0\n\t\tfor num in nums:\n\t\t\tcount = 0\n\t\t\twhile num != 0:\n\t\t\t\tif num % 2:\n\t\t\t\t\tres += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tnum //= 2\n\t\t\tmax_mult = max(max_mult, count)\n\t\treturn res + max_mult\n", "from collections import Counter, defaultdict, OrderedDict, deque\nfrom bisect import bisect_left, bisect_right\nfrom functools import reduce, lru_cache\nfrom typing import List\nimport itertools\nimport math\nimport heapq\nimport string\ntrue = True\nfalse = False\n(MIN, MAX, MOD) = (-1061109567, 1061109567, 1000000007)\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt = 0\n\t\tcc = Counter(nums)\n\t\twhile True:\n\t\t\tdup = defaultdict(int)\n\t\t\tdo_even = False\n\t\t\tfor n in cc:\n\t\t\t\tif n == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tif n % 2:\n\t\t\t\t\tcnt += cc[n]\n\t\t\t\t\tif n - 1 > 0:\n\t\t\t\t\t\tdo_even = True\n\t\t\t\t\t\tdup[n // 2] += cc[n]\n\t\t\t\telse:\n\t\t\t\t\tdo_even = True\n\t\t\t\t\tdup[n // 2] += cc[n]\n\t\t\tif do_even:\n\t\t\t\tcnt += 1\n\t\t\tif not dup:\n\t\t\t\treturn cnt\n\t\t\tcc = dup\n\t\treturn cnt\nsol = Solution()\nnums = [1, 5]\nnums = [2, 2]\nnums = [4, 2, 5]\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tnz = 0\n\t\tfor num in nums:\n\t\t\tif num > 0:\n\t\t\t\tnz += 1\n\t\twhile nz > 0:\n\t\t\tdiv2 = False\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tnz -= 1\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tdiv2 = True\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tnz -= 1\n\t\t\tif div2:\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tgoal = [0] * len(nums)\n\t\tif nums == goal:\n\t\t\treturn 0\n\t\tcalls = 0\n\t\tdiv_needed = False\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 == 1:\n\t\t\t\tnums[i] -= 1\n\t\t\t\tcalls += 1\n\t\t\tif nums[i] > 0:\n\t\t\t\tdiv_needed = True\n\t\tif div_needed:\n\t\t\tnums = [n / 2 for n in nums]\n\t\t\tcalls += 1\n\t\treturn calls + self.minOperations(nums)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile sum(nums) != 0:\n\t\t\tcount_odd = 0\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num % 2 != 0:\n\t\t\t\t\tcount_odd += 1\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\tif count_odd == 0:\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, a: List[int]) -> int:\n\t\tans = 0\n\t\twhile True:\n\t\t\ta.sort(reverse=True)\n\t\t\tfor i in range(len(a)):\n\t\t\t\tif a[i] % 2:\n\t\t\t\t\tans += 1\n\t\t\t\t\ta[i] -= 1\n\t\t\tfor i in a:\n\t\t\t\tif i != 0:\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tbreak\n\t\t\tfor i in range(len(a)):\n\t\t\t\tif a[i] % 2 == 0:\n\t\t\t\t\ta[i] //= 2\n\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, A: List[int]) -> int:\n\t\treturn sum((bin(a).count('1') for a in A)) + len(bin(max(A))) - 3\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\tdone = False\n\t\twhile not done:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tops += 1\n\t\t\tdone = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tdone = False\n\t\t\t\t\tnums[i] /= 2\n\t\t\tif not done:\n\t\t\t\tops += 1\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxDoubles = 0\n\t\tincrs = 0\n\t\tfor num in nums:\n\t\t\tdoubles = 0\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tincrs += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\tdoubles += 1\n\t\t\t\t\tnum >>= 1\n\t\t\tmaxDoubles = max(maxDoubles, doubles)\n\t\treturn incrs + maxDoubles\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tsum1 = 1\n\t\twhile sum1 != 0:\n\t\t\tsum1 = 0\n\t\t\tfor (ii, i) in enumerate(nums):\n\t\t\t\tif i % 2 != 0:\n\t\t\t\t\tnums[ii] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\tnums[ii] = nums[ii] // 2\n\t\t\t\tsum1 += nums[ii]\n\t\t\tres += 1\n\t\treturn res - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tactions = 0\n\t\tn = len(nums)\n\t\twhile True:\n\t\t\todd_flag = False\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tactions += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\todd_flag = True\n\t\t\tif all((num == 0 for num in nums)):\n\t\t\t\tbreak\n\t\t\tif odd_flag:\n\t\t\t\tcontinue\n\t\t\tfor i in range(n):\n\t\t\t\tnums[i] //= 2\n\t\t\tactions += 1\n\t\t\tif all((num == 0 for num in nums)):\n\t\t\t\tbreak\n\t\treturn actions\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile True:\n\t\t\tnext_nums = [0] * len(nums)\n\t\t\tall_zeros = True\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif x == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tif x % 2 != 0:\n\t\t\t\t\tcount += 1\n\t\t\t\tnext_num = x // 2\n\t\t\t\tnext_nums[i] = next_num\n\t\t\t\tall_zeros &= next_num == 0\n\t\t\tif all_zeros:\n\t\t\t\tbreak\n\t\t\tcount += 1\n\t\t\tnums = next_nums\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tL = lambda x: len(x)\n\t\top = 0\n\t\twhile sum(nums):\n\t\t\tisodd = False\n\t\t\tfor i in range(L(nums)):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tisodd = True\n\t\t\t\t\top += 1\n\t\t\tif not isodd:\n\t\t\t\tfor i in range(L(nums)):\n\t\t\t\t\tnums[i] >>= 1\n\t\t\t\top += 1\n\t\treturn op\n", "class Solution:\n\n\tdef minOperations(self, nums):\n\t\tans = 0\n\t\tmaxtimes = 0\n\t\tfor num in nums:\n\t\t\t(plus, times) = (0, 0)\n\t\t\twhile num != 0:\n\t\t\t\tplus = plus + num % 2\n\t\t\t\tif num // 2 != 0:\n\t\t\t\t\ttimes += 1\n\t\t\t\tnum = num // 2\n\t\t\tmaxtimes = max(maxtimes, times)\n\t\t\tans = ans + plus\n\t\tans += maxtimes\n\t\treturn ans\nx = Solution()\nprint(x.minOperations([1, 5]))\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif max(nums) == 0:\n\t\t\treturn 0\n\t\toperations = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 == 1:\n\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\toperations += 1\n\t\tif operations > 0:\n\t\t\treturn operations + self.minOperations(nums)\n\t\tfor i in range(len(nums)):\n\t\t\tnums[i] = nums[i] // 2\n\t\toperations += 1\n\t\treturn operations + self.minOperations(nums)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_ = max(nums)\n\t\tmultiplication = len(bin(max_)[2:]) - 1\n\t\tadditions = 0\n\t\tfor n in nums:\n\t\t\tadditions += bin(n)[2:].count('1')\n\t\treturn additions + multiplication\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tc = 0\n\t\twhile True:\n\t\t\tsol = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tc += 1\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tsol = False\n\t\t\tif sol:\n\t\t\t\tbreak\n\t\t\tc += 1\n\t\t\tnums = [x // 2 for x in nums]\n\t\treturn c\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile any([True if num > 0 else False for num in nums]):\n\t\t\tfor (idx, num) in enumerate(nums):\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[idx] -= 1\n\t\t\tflag = 0\n\t\t\tfor (idx, num) in enumerate(nums):\n\t\t\t\tif num != 0:\n\t\t\t\t\tflag = True\n\t\t\t\t\tnums[idx] = num // 2\n\t\t\tif flag:\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tN = len(nums)\n\t\tc = 0\n\t\twhile any(nums):\n\t\t\tfor i in range(N):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tc += 1\n\t\t\tm = max(nums)\n\t\t\tfor i in range(N):\n\t\t\t\tnums[i] >>= 1\n\t\t\tc += 1\n\t\treturn c - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmul = [0 for i in range(len(nums))]\n\t\tinc = [0 for i in range(len(nums))]\n\t\tfor i in range(len(nums)):\n\t\t\twhile nums[i] != 0:\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tinc[i] += 1\n\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\telse:\n\t\t\t\t\tmul[i] += 1\n\t\t\t\t\tnums[i] //= 2\n\t\treturn max(mul) + sum(inc)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef get_op(n):\n\t\t\top_0 = 0\n\t\t\top_1 = 0\n\t\t\twhile n != 0:\n\t\t\t\tif n % 2 == 0:\n\t\t\t\t\top_1 += 1\n\t\t\t\t\tn = n // 2\n\t\t\t\telse:\n\t\t\t\t\top_0 += 1\n\t\t\t\t\tn -= 1\n\t\t\treturn (op_0, op_1)\n\t\tans = 0\n\t\top_1 = 0\n\t\tfor n in nums:\n\t\t\t(tmp_0, tmp_1) = get_op(n)\n\t\t\tans += tmp_0\n\t\t\top_1 = max(op_1, tmp_1)\n\t\treturn ans + op_1\n", "from functools import lru_cache\n\nclass Solution:\n\n\tdef minOperations(self, nums) -> int:\n\n\t\t@lru_cache(None)\n\t\tdef minOpt(num):\n\t\t\tif num == 0:\n\t\t\t\treturn (0, 0)\n\t\t\tif num % 2 == 1:\n\t\t\t\t(m, a) = minOpt(num - 1)\n\t\t\t\treturn (m, a + 1)\n\t\t\telse:\n\t\t\t\t(m, a) = minOpt(num // 2)\n\t\t\t\treturn (m + 1, a)\n\t\t(multiply, add) = (0, 0)\n\t\tfor num in nums:\n\t\t\t(m, a) = minOpt(num)\n\t\t\tmultiply = max(m, multiply)\n\t\t\tadd += a\n\t\treturn multiply + add\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tt = 0\n\t\th = nums[0]\n\t\tfor n in nums:\n\t\t\tif n > h:\n\t\t\t\th = n\n\t\t\twhile n:\n\t\t\t\tn &= n - 1\n\t\t\t\tt += 1\n\t\tif h > 0:\n\t\t\treturn t + math.floor(math.log(h, 2))\n\t\treturn t\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tones = 0\n\t\ttwo = 0\n\t\tfor i in nums:\n\t\t\tmul = 0\n\t\t\twhile i:\n\t\t\t\tif i % 2 == 1:\n\t\t\t\t\ti = i - 1\n\t\t\t\t\tones += 1\n\t\t\t\telse:\n\t\t\t\t\ti = i // 2\n\t\t\t\t\tmul += 1\n\t\t\ttwo = max(two, mul)\n\t\treturn ones + two\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(inc, mult) = (0, 0)\n\t\tfor i in nums:\n\t\t\tif i:\n\t\t\t\t(a, b) = self.getRes(i)\n\t\t\t\tinc += a\n\t\t\t\tmult = max(mult, b)\n\t\treturn inc + mult\n\n\tdef getRes(self, n):\n\t\t(inc, mult) = (0, 0)\n\t\twhile n:\n\t\t\tif n % 2 == 1:\n\t\t\t\tn -= 1\n\t\t\t\tinc += 1\n\t\t\telse:\n\t\t\t\tn //= 2\n\t\t\t\tmult += 1\n\t\treturn (inc, mult)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\twhile len(nums) > 0:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\top += 1\n\t\t\tnums = list(filter(lambda x: x != 0, nums))\n\t\t\tif len(nums) > 0:\n\t\t\t\tnums[:] = [int(x / 2) for x in nums]\n\t\t\t\top += 1\n\t\treturn op\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\to = 0\n\t\tm = 0\n\t\ta = 0\n\t\tfor i in nums:\n\t\t\tm = 0\n\t\t\twhile i:\n\t\t\t\tif i % 2 == 0:\n\t\t\t\t\tm += 1\n\t\t\t\t\ti //= 2\n\t\t\t\telse:\n\t\t\t\t\to += 1\n\t\t\t\t\ti -= 1\n\t\t\ta = max(m, a)\n\t\treturn o + a\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tlst = list(map(find_op, nums))\n\t\tmul = max(lst, key=lambda x: x[0])\n\t\tmul = mul[0]\n\t\tadd = sum([item[1] for item in lst])\n\t\treturn add + mul\n\ndef find_op(n):\n\t(mul, add) = (0, 0)\n\twhile n > 0:\n\t\tif n % 2 == 1:\n\t\t\tadd += 1\n\t\tn //= 2\n\t\tmul += 1\n\tif mul > 0:\n\t\tmul -= 1\n\treturn (mul, add)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount_zeros = 0\n\t\tfor i in nums:\n\t\t\tif i == 0:\n\t\t\t\tcount_zeros += 1\n\t\toperations = 0\n\t\twhile count_zeros != len(nums):\n\t\t\todd_max = -1\n\t\t\tfor i in range(0, len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\toperations += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\todd_max = i\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tcount_zeros += 1\n\t\t\tif odd_max == -1:\n\t\t\t\toperations += 1\n\t\t\t\tfor i in range(0, len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\treturn operations\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\treturn sum((bin(a).count('1') for a in nums)) + len(bin(max(nums))[2:]) - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2:\n\t\t\t\tnums[i] -= 1\n\t\t\t\tres += 1\n\t\tif any(nums):\n\t\t\tnums = [i // 2 for i in nums]\n\t\t\treturn res + 1 + self.minOperations(nums)\n\t\telse:\n\t\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tarr = nums[:]\n\t\tres = 0\n\t\twhile any(arr):\n\t\t\todd = sum([x % 2 == 1 for x in arr])\n\t\t\tif odd:\n\t\t\t\tarr = [x - x % 2 for x in arr]\n\t\t\t\tres += odd\n\t\t\telse:\n\t\t\t\tarr = [x // 2 for x in arr]\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\twhile any(nums):\n\t\t\tones = sum((num & 1 for num in nums))\n\t\t\tres += ones\n\t\t\tnums = [num >> 1 for num in nums]\n\t\t\tres += 1\n\t\treturn res - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\ta = [0] * len(nums)\n\t\twhile nums != a:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 0:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\telse:\n\t\t\t\t\top += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\top += 1\n\t\treturn op - 1\n", "class Solution:\n\n\tdef minOperations(self, nums):\n\t\tret = []\n\t\toverall = 0\n\t\tfor i in nums:\n\t\t\ttemp = 0\n\t\t\tif i == 0:\n\t\t\t\toverall -= 1\n\t\t\tif i % 2 == 1 and i != 1:\n\t\t\t\toverall += 1\n\t\t\t\ti -= 1\n\t\t\twhile i > 1:\n\t\t\t\tif i % 2 == 1:\n\t\t\t\t\toverall += 1\n\t\t\t\t\ti -= 1\n\t\t\t\telse:\n\t\t\t\t\ttemp += 1\n\t\t\t\t\ti /= 2\n\t\t\tret.append(temp)\n\t\treturn overall + max(ret) + len(ret)\n", "class Solution:\n\n\tdef getOdd(self, nums):\n\t\tfor (i, n) in enumerate(nums):\n\t\t\tif n % 2 == 1:\n\t\t\t\treturn i\n\t\treturn None\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\twhile nums.count(0) != len(nums):\n\t\t\todd = self.getOdd(nums)\n\t\t\tif odd is None:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tres += 1\n\t\t\telse:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums) -> int:\n\t\ta = list(sorted(nums))\n\t\tmoves = 0\n\t\twhile True:\n\t\t\tfor i in range(len(a)):\n\t\t\t\tif a[i] % 2 == 1:\n\t\t\t\t\tmoves += 1\n\t\t\t\t\ta[i] -= 1\n\t\t\tremaining = 0\n\t\t\tfor i in range(len(a)):\n\t\t\t\tif a[i] > 0:\n\t\t\t\t\tremaining += 1\n\t\t\tif remaining == 0:\n\t\t\t\tbreak\n\t\t\tmoves += 1\n\t\t\tfor i in range(len(a)):\n\t\t\t\ta[i] = a[i] // 2\n\t\treturn moves\n", "class Solution:\n\n\tdef minOperations(self, A):\n\t\t(steps, n) = (0, len(A))\n\t\twhile True:\n\t\t\tzeros = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif A[i] % 2 > 0:\n\t\t\t\t\tA[i] -= 1\n\t\t\t\t\tsteps += 1\n\t\t\t\tif A[i] == 0:\n\t\t\t\t\tzeros += 1\n\t\t\tif zeros == n:\n\t\t\t\tbreak\n\t\t\tfor i in range(n):\n\t\t\t\tA[i] >>= 1\n\t\t\tsteps += 1\n\t\treturn steps\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(zeros, ops) = (0, 0)\n\t\twhile zeros != len(nums):\n\t\t\t(odds, evens, zeros) = (0, 0, 0)\n\t\t\tfor i in range(0, len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\todds += 1\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tzeros += 1\n\t\t\t\telse:\n\t\t\t\t\tevens += 1\n\t\t\t\t\tnums[i] //= 2\n\t\t\tops += odds\n\t\t\tops += 1 if evens else 0\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top1 = op2 = 0\n\t\tfor num in nums:\n\t\t\tcount1 = count2 = 0\n\t\t\twhile num:\n\t\t\t\tif num & 1:\n\t\t\t\t\tcount1 += num & 1\n\t\t\t\t\tnum -= 1\n\t\t\t\tif num:\n\t\t\t\t\tcount2 += 1\n\t\t\t\tnum >>= 1\n\t\t\top1 += count1\n\t\t\top2 = max(op2, count2)\n\t\treturn op1 + op2\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(res, val) = (0, sum(nums))\n\t\twhile val:\n\t\t\tval0 = val\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif x % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tval -= 1\n\t\t\tres += val0 - val\n\t\t\tif val == val0:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\tval //= 2\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tminops = 0\n\t\twhile sum(nums) > 0:\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num & 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tminops += 1\n\t\t\tnums = [num >> 1 for num in nums]\n\t\t\tminops += 1\n\t\treturn minops - 1\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxn = 0\n\t\tres = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] > 0:\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tcount = 0\n\t\t\t\t\tn = nums[i]\n\t\t\t\t\twhile n > 0:\n\t\t\t\t\t\tif n % 2 > 0:\n\t\t\t\t\t\t\tres += 1\n\t\t\t\t\t\t\tn = n - 1\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\tcount += 1\n\t\t\t\t\t\t\tn = n // 2\n\t\t\t\t\tif count > maxn:\n\t\t\t\t\t\tmaxn = count\n\t\treturn res + maxn\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\todds: List[int] = [n for n in nums if n % 2 == 1]\n\t\tevens: Set[int] = [n for n in nums if n != 0 and n % 2 == 0]\n\t\tnew: List[int] = []\n\t\tn: int = 0\n\t\tn_ops: int = 0\n\t\twhile len(odds) > 0 or len(evens) > 0:\n\t\t\tif len(odds) > 0:\n\t\t\t\tn = odds.pop() - 1\n\t\t\t\tif n > 0:\n\t\t\t\t\tevens.append(n)\n\t\t\telse:\n\t\t\t\tnew = [n // 2 for n in evens]\n\t\t\t\todds = [n for n in new if n % 2 == 1]\n\t\t\t\tevens = [n for n in new if n % 2 == 0]\n\t\t\tn_ops += 1\n\t\treturn n_ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef minSteps(num):\n\t\t\tif num == 1:\n\t\t\t\treturn 1\n\t\t\tif num in memo:\n\t\t\t\treturn memo[num]\n\t\t\tmemo[num] = minSteps(num // 2) if num % 2 == 0 else 1 + minSteps(num - 1)\n\t\t\treturn memo[num]\n\n\t\tdef countPowerOfTwo(num):\n\t\t\tif num < 2:\n\t\t\t\treturn 0\n\t\t\t(cnt, cur) = (1, 2)\n\t\t\twhile cur * 2 <= num:\n\t\t\t\tcnt += 1\n\t\t\t\tcur <<= 1\n\t\t\treturn cnt\n\t\tmemo = {}\n\t\tres = countPowerOfTwo(max(nums))\n\t\tfor num in nums:\n\t\t\tif num == 0:\n\t\t\t\tcontinue\n\t\t\tres += minSteps(num)\n\t\treturn res\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tp = []\n\t\tans = 0\n\t\tfor i in nums:\n\t\t\tr = 0\n\t\t\twhile i > 0:\n\t\t\t\tif i % 2 == 0:\n\t\t\t\t\tr += 1\n\t\t\t\t\ti /= 2\n\t\t\t\telse:\n\t\t\t\t\tans += 1\n\t\t\t\t\ti -= 1\n\t\t\tp.append(r)\n\t\tans += max(p)\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tmax_count = 0\n\t\tfor num in nums:\n\t\t\tcnt = 0\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 != 0:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\tans += 1\n\t\t\t\telse:\n\t\t\t\t\tnum /= 2\n\t\t\t\t\tcnt += 1\n\t\t\tmax_count = max(max_count, cnt)\n\t\treturn ans + max_count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tbig = 0\n\t\tfor i in range(len(nums)):\n\t\t\tk = nums[i]\n\t\t\tk = bin(k)\n\t\t\tans += k.count('1')\n\t\t\tbig = max(big, 0, len(k) - 3)\n\t\tans += big\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef get_counts(x):\n\t\t\tif x == 0:\n\t\t\t\treturn (0, 0)\n\t\t\telif x % 2 == 0:\n\t\t\t\t(add_count, mul_count) = get_counts(x // 2)\n\t\t\t\treturn (add_count, mul_count + 1)\n\t\t\telse:\n\t\t\t\t(add_count, mul_count) = get_counts(x - 1)\n\t\t\t\treturn (add_count + 1, mul_count)\n\t\t(add_count, mul_count) = (0, 0)\n\t\tfor num in nums:\n\t\t\t(ac, mc) = get_counts(num)\n\t\t\tadd_count += ac\n\t\t\tmul_count = max(mc, mul_count)\n\t\treturn add_count + mul_count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\twhile True:\n\t\t\tdoDivision = 0\n\t\t\tNoZero = 1\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tNoZero = 0\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\top += 1\n\t\t\t\tif nums[i] != 1 and nums[i] != 0:\n\t\t\t\t\tdoDivision = 1\n\t\t\t\t\tnums[i] //= 2\n\t\t\tif doDivision == 1:\n\t\t\t\top += 1\n\t\t\tif NoZero == 1:\n\t\t\t\treturn op\n", "from typing import Tuple\n\nclass Solution:\n\n\tdef ones_twos(self, n: int, ones: int, twos: int) -> Tuple[int, int]:\n\t\tif n == 0:\n\t\t\treturn (ones, twos)\n\t\tif n == 1:\n\t\t\treturn (ones + 1, twos)\n\t\tif n % 2 == 0:\n\t\t\treturn self.ones_twos(n // 2, ones, twos + 1)\n\t\telse:\n\t\t\treturn self.ones_twos(n - 1, ones + 1, twos)\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(ones, twos) = (0, 0)\n\t\tfor num in nums:\n\t\t\t(o, t) = self.ones_twos(num, 0, 0)\n\t\t\tones += o\n\t\t\ttwos = max(twos, t)\n\t\treturn ones + twos\n", "class Solution1:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttwos = 0\n\t\tones = 0\n\t\tfor n in nums:\n\t\t\tmul = 0\n\t\t\twhile n:\n\t\t\t\tif n % 2:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tones += 1\n\t\t\t\telse:\n\t\t\t\t\tn //= 2\n\t\t\t\t\tmul += 1\n\t\t\ttwos = max(twos, mul)\n\t\treturn ones + twos\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxval = max(nums)\n\t\tidx = nums.index(maxval)\n\t\tans = 0\n\t\twhile nums[idx] != 0:\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tans += n % 2\n\t\t\t\tnums[i] = n - n % 2\n\t\t\tif nums[idx] != 0:\n\t\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\ta = [x for x in nums if x]\n\t\twhile a:\n\t\t\tfor (i, x) in enumerate(a):\n\t\t\t\tif x & 1:\n\t\t\t\t\ta[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\ta = [x // 2 for x in a if x]\n\t\t\tif a:\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tlru_cache(maxsize=None)\n\n\t\tdef check(n):\n\t\t\tif n == 0:\n\t\t\t\treturn (0, 0)\n\t\t\telif n == 1:\n\t\t\t\treturn (1, 0)\n\t\t\telse:\n\t\t\t\tr1 = 0\n\t\t\t\tr2 = 0\n\t\t\t\t(k, l) = divmod(n, 2)\n\t\t\t\t(r1, r2) = check(k)\n\t\t\t\tr1 += l\n\t\t\t\tr2 += 1\n\t\t\treturn (r1, r2)\n\t\tr1 = 0\n\t\tr2 = 0\n\t\tfor n in nums:\n\t\t\t(c1, c2) = check(n)\n\t\t\tr1 += c1\n\t\t\tr2 = max(r2, c2)\n\t\treturn r1 + r2\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tzeros = []\n\t\toperations = 0\n\t\tfor item in nums:\n\t\t\tzeros.append(0)\n\t\twhile nums != zeros:\n\t\t\tfor (index, item) in enumerate(nums):\n\t\t\t\tif item % 2 == 1:\n\t\t\t\t\tnums[index] = item - 1\n\t\t\t\t\toperations += 1\n\t\t\tif nums == zeros:\n\t\t\t\tbreak\n\t\t\tfor (index, item) in enumerate(nums):\n\t\t\t\tif item % 2 == 0:\n\t\t\t\t\tnums[index] = item / 2\n\t\t\toperations += 1\n\t\treturn operations\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tcount = collections.Counter()\n\t\tfor n in nums:\n\t\t\tif n != 0:\n\t\t\t\tcount[n] += 1\n\t\twhile len(count) > 0:\n\t\t\tnewcount = collections.Counter()\n\t\t\tfor (k, v) in count.items():\n\t\t\t\tif k % 2 == 0:\n\t\t\t\t\tnewcount[k // 2] += v\n\t\t\t\telif k > 1:\n\t\t\t\t\tnewcount[(k - 1) // 2] += v\n\t\t\t\t\tans += v\n\t\t\t\telse:\n\t\t\t\t\tans += v\n\t\t\tans += 1\n\t\t\tcount = newcount\n\t\treturn ans - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef _op(arr):\n\t\t\t(odds, zeros) = (0, 0)\n\t\t\tfor i in range(len(arr)):\n\t\t\t\tif arr[i] == 0:\n\t\t\t\t\tzeros += 1\n\t\t\t\telif arr[i] % 2 == 1:\n\t\t\t\t\tarr[i] -= 1\n\t\t\t\t\todds += 1\n\t\t\tif zeros == len(arr):\n\t\t\t\treturn 0\n\t\t\tif odds != 0:\n\t\t\t\treturn odds\n\t\t\tfor i in range(len(arr)):\n\t\t\t\tarr[i] //= 2\n\t\t\treturn 1\n\t\tans = 0\n\t\tops = _op(nums)\n\t\twhile ops != 0:\n\t\t\tans += ops\n\t\t\tops = _op(nums)\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\tif not any((n != 0 for n in nums)):\n\t\t\treturn 0\n\t\twhile nums:\n\t\t\tif any((n % 2 != 0 for n in nums)):\n\t\t\t\tfor (idx, n) in enumerate(nums):\n\t\t\t\t\tif nums[idx] % 2 != 0:\n\t\t\t\t\t\tnums[idx] -= 1\n\t\t\t\t\t\tops += 1\n\t\t\t\tnums = [n for n in nums if n != 0]\n\t\t\telse:\n\t\t\t\tops += 1\n\t\t\t\tnums = [int(n / 2) for n in nums]\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tsteps = 0\n\t\tnums = sorted(nums)\n\t\tj = -1\n\t\twhile j < len(nums) - 1:\n\t\t\ts = j + 1\n\t\t\twhile s < len(nums):\n\t\t\t\tif nums[s] == 0:\n\t\t\t\t\tj += 1\n\t\t\t\telif nums[s] == 1:\n\t\t\t\t\tsteps += 1\n\t\t\t\t\tj += 1\n\t\t\t\t\tnums[s] = 0\n\t\t\t\telif nums[s] % 2 == 1:\n\t\t\t\t\tsteps += 1\n\t\t\t\t\tnums[s] -= 1\n\t\t\t\t\tnums[s] //= 2\n\t\t\t\telse:\n\t\t\t\t\tnums[s] //= 2\n\t\t\t\ts += 1\n\t\t\tsteps += 1\n\t\treturn steps - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef do(n):\n\t\t\t(a, b) = (0, 0)\n\t\t\twhile n != 0:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\ta += 1\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\tb += 1\n\t\t\t\t\tn //= 2\n\t\t\treturn [a, b]\n\t\t(aa, bb) = (0, 0)\n\t\tfor n in nums:\n\t\t\t(a, b) = do(n)\n\t\t\taa += a\n\t\t\tbb = max(b, bb)\n\t\treturn aa + bb\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\td = max(nums)\n\t\tif d == 0:\n\t\t\treturn 0\n\t\tres = 0\n\t\twhile d >= 2:\n\t\t\tres += 1\n\t\t\td >>= 1\n\t\tfor num in nums:\n\t\t\twhile num:\n\t\t\t\tres += 1\n\t\t\t\tnum &= num - 1\n\t\treturn res\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tpower = [0] * n\n\t\trem = [0] * n\n\t\tfor i in range(n):\n\t\t\tj = nums[i]\n\t\t\tcount1 = 0\n\t\t\tcount2 = 0\n\t\t\twhile j > 0:\n\t\t\t\tif j % 2 == 0:\n\t\t\t\t\tcount1 += 1\n\t\t\t\t\tj = j // 2\n\t\t\t\telse:\n\t\t\t\t\tcount2 += 1\n\t\t\t\t\tj = j - 1\n\t\t\t(power[i], rem[i]) = (count1, count2)\n\t\tans = max(power) + sum(rem)\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tarr = [0] * len(nums)\n\t\tif arr == nums:\n\t\t\treturn 0\n\t\tops = 0\n\t\twhile arr != nums:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tops += 1\n\t\t\tops += 1\n\t\t\tnums = [x / 2 for x in nums]\n\t\treturn ops - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef odd_2_even(nums):\n\t\t\tstep = 0\n\t\t\tnew_nums = []\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tstep += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tif nums[i] > 0:\n\t\t\t\t\t\tnew_nums.append(nums[i])\n\t\t\t\telif nums[i] > 0:\n\t\t\t\t\tnew_nums.append(nums[i])\n\t\t\treturn (step, new_nums)\n\n\t\tdef even_2(nums):\n\t\t\treturn [a // 2 for a in nums]\n\t\tstep = 0\n\t\twhile len(nums) > 0:\n\t\t\t(add, nums) = odd_2_even(nums)\n\t\t\tif len(nums) > 0:\n\t\t\t\tnums = even_2(nums)\n\t\t\t\tstep += 1\n\t\t\tstep = step + add\n\t\treturn step\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcost = 0\n\t\td = 0\n\t\tfor a in nums:\n\t\t\t(division, increments) = self.trick(a)\n\t\t\td = max(division, d)\n\t\t\tcost += increments\n\t\treturn d + cost\n\n\tdef trick(self, mx):\n\t\tif mx in {0, 1}:\n\t\t\treturn (0, 0) if mx == 0 else (0, 1)\n\t\tif mx % 2 == 0:\n\t\t\t(d, i) = self.trick(mx // 2)\n\t\t\treturn (d + 1, i)\n\t\telse:\n\t\t\t(d, i) = self.trick(mx - 1)\n\t\t\treturn (d, i + 1)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = 0\n\t\tresult_num_div = 0\n\t\tfor i in range(len(nums)):\n\t\t\tnum_div = 0\n\t\t\twhile nums[i] > 0:\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tresult += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\tif nums[i] > 1:\n\t\t\t\t\tnum_div += 1\n\t\t\t\tnums[i] /= 2\n\t\t\tresult_num_div = max(result_num_div, num_div)\n\t\treturn result + result_num_div\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tn = len(nums)\n\t\twhile True:\n\t\t\ti = 0\n\t\t\tzc = 0\n\t\t\twhile i < n:\n\t\t\t\tif nums[i] & 1 > 0:\n\t\t\t\t\tbreak\n\t\t\t\telif nums[i] == 0:\n\t\t\t\t\tzc += 1\n\t\t\t\ti += 1\n\t\t\tif zc == n:\n\t\t\t\treturn res\n\t\t\tif i == n:\n\t\t\t\tfor j in range(n):\n\t\t\t\t\tnums[j] = nums[j] // 2\n\t\t\t\tres += 1\n\t\t\tfor j in range(i, n):\n\t\t\t\tif nums[j] & 1:\n\t\t\t\t\tnums[j] -= 1\n\t\t\t\t\tres += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef count_ops(x: int) -> int:\n\t\t\tif x == 0:\n\t\t\t\treturn (0, 0)\n\t\t\telif x == 1:\n\t\t\t\treturn (1, 0)\n\t\t\telif x % 2 == 0:\n\t\t\t\t(add, mul) = count_ops(x // 2)\n\t\t\t\treturn (add, mul + 1)\n\t\t\telse:\n\t\t\t\t(add, mul) = count_ops(x - 1)\n\t\t\t\treturn (add + 1, mul)\n\t\tcount = maxmul = 0\n\t\tfor i in nums:\n\t\t\t(add, mul) = count_ops(i)\n\t\t\tmaxmul = max(maxmul, mul)\n\t\t\tcount += add\n\t\treturn count + maxmul\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tcnt = len(nums)\n\t\tfor n in nums:\n\t\t\tif n == 0:\n\t\t\t\tcnt -= 1\n\t\twhile cnt > 0:\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n != 0 and n % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tans += 1\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tcnt -= 1\n\t\t\ttwo = 0\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n != 0 and n % 2 == 0:\n\t\t\t\t\ttwo = 1\n\t\t\t\t\tnums[i] //= 2\n\t\t\tans += two\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tarr = [0] * len(nums)\n\t\tcount = 0\n\t\twhile nums != arr:\n\t\t\tcheck = True\n\t\t\tfor x in nums:\n\t\t\t\tif x % 2 != 0:\n\t\t\t\t\tcheck = False\n\t\t\tif check == True:\n\t\t\t\tcount += 1\n\t\t\t\tfor x in range(len(nums)):\n\t\t\t\t\tnums[x] = nums[x] // 2\n\t\t\tfor x in range(len(nums)):\n\t\t\t\tif nums[x] % 2 != 0:\n\t\t\t\t\tnums[x] = nums[x] - 1\n\t\t\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tout = 0\n\t\twhile sum(nums) != 0:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tout += 1\n\t\t\tif sum(nums) == 0:\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] /= 2\n\t\t\tout += 1\n\t\treturn out\n", "from copy import deepcopy\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef modify(arr, op, idx):\n\t\t\tif op == 0:\n\t\t\t\tarr[idx] = arr[idx] - 1\n\t\t\telif op == 1:\n\t\t\t\tfor (i, num) in enumerate(arr):\n\t\t\t\t\tarr[i] = num // 2\n\t\tzeros = [0] * len(nums)\n\t\tans = 0\n\t\twhile True:\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tnums[i] = num - 1\n\t\t\t\t\tans += 1\n\t\t\tif nums == zeros:\n\t\t\t\treturn ans\n\t\t\telse:\n\t\t\t\tmodify(nums, 1, 0)\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\tN = len(nums)\n\t\twhile True:\n\t\t\tn = 0\n\t\t\talleven = True\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num == 0:\n\t\t\t\t\tn += 1\n\t\t\t\telif num % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tif num == 0:\n\t\t\t\t\t\tn += 1\n\t\t\t\t\talleven = False\n\t\t\t\t\tops += 1\n\t\t\tif n == N:\n\t\t\t\tbreak\n\t\t\tif alleven:\n\t\t\t\tfor i in range(N):\n\t\t\t\t\tif nums[i]:\n\t\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tops += 1\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = 0\n\t\twhile True:\n\t\t\tto_continue = False\n\t\t\tops = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\telif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tops += 1\n\t\t\t\t\tto_continue = True\n\t\t\t\telse:\n\t\t\t\t\tto_continue = True\n\t\t\tif ops > 0:\n\t\t\t\tresult += ops\n\t\t\telif to_continue:\n\t\t\t\tresult += 1\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] //= 2\n\t\t\telse:\n\t\t\t\tbreak\n\t\treturn result\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tval = max(nums)\n\t\tdouble = 0\n\t\tadd = 0\n\t\tvalue = 0\n\t\tcount = 0\n\t\tvalue = val\n\t\twhile value != 0:\n\t\t\tif value % 2 == 0:\n\t\t\t\tvalue = value // 2\n\t\t\t\tdouble += 1\n\t\t\telse:\n\t\t\t\tvalue -= 1\n\t\t\t\tadd += 1\n\t\tcount += double\n\t\tprint(add, double)\n\t\tfor x in nums:\n\t\t\tvalue = x\n\t\t\thalf = 0\n\t\t\tadd = 0\n\t\t\twhile value != 0:\n\t\t\t\tif value % 2 == 0:\n\t\t\t\t\tvalue = value // 2\n\t\t\t\t\thalf += 1\n\t\t\t\telse:\n\t\t\t\t\tvalue -= 1\n\t\t\t\t\tadd += 1\n\t\t\tcount += add\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tnums = [num for num in nums if num]\n\t\tif not nums:\n\t\t\treturn 0\n\t\twhile nums:\n\t\t\tflag = False\n\t\t\tnew_nums = []\n\t\t\tfor num in nums:\n\t\t\t\tif num % 2:\n\t\t\t\t\tflag = True\n\t\t\t\t\tbreak\n\t\t\tif flag:\n\t\t\t\tfor num in nums:\n\t\t\t\t\tif num % 2:\n\t\t\t\t\t\tnum = num - 1\n\t\t\t\t\t\tcount += 1\n\t\t\t\t\tif num:\n\t\t\t\t\t\tnew_nums.append(num)\n\t\t\telse:\n\t\t\t\tfor num in nums:\n\t\t\t\t\tnew_nums.append(num / 2)\n\t\t\t\tcount += 1\n\t\t\tnums = new_nums\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\toperations = 0\n\t\twhile not all((n == 0 for n in nums)):\n\t\t\tif all((n % 2 == 0 for n in nums)):\n\t\t\t\tnums = [n / 2 for n in nums]\n\t\t\t\toperations += 1\n\t\t\telse:\n\t\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\t\tif num % 2 != 0:\n\t\t\t\t\t\tnums[i] = num - 1\n\t\t\t\t\t\toperations += 1\n\t\treturn operations\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans_count = 0\n\t\twhile True:\n\t\t\tzero_count = 0\n\t\t\thave_odd = False\n\t\t\tfor idx in range(len(nums)):\n\t\t\t\tif nums[idx] % 2 != 0:\n\t\t\t\t\thave_odd = True\n\t\t\t\t\tans_count += 1\n\t\t\t\t\tnums[idx] -= 1\n\t\t\t\tif nums[idx] == 0:\n\t\t\t\t\tzero_count += 1\n\t\t\tif zero_count == len(nums):\n\t\t\t\tbreak\n\t\t\tif not have_odd:\n\t\t\t\tans_count += 1\n\t\t\t\tfor idx in range(len(nums)):\n\t\t\t\t\tnums[idx] //= 2\n\t\treturn ans_count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tsol = nums\n\t\tcost = 0\n\t\twhile sum(sol) > 0:\n\t\t\tfor i in range(len(sol)):\n\t\t\t\tif sol[i] & 1 != 0:\n\t\t\t\t\tsol[i] -= 1\n\t\t\t\t\tcost += 1\n\t\t\tif len(sol) > 0:\n\t\t\t\tsol = [x // 2 for x in sol if x > 0]\n\t\t\t\tif len(sol) > 0:\n\t\t\t\t\tcost += 1\n\t\treturn cost\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tdelete_count = 0\n\t\tdivide_count = 0\n\t\tfor e in nums:\n\t\t\tdivide = 0\n\t\t\twhile e != 0:\n\t\t\t\tif e % 2:\n\t\t\t\t\te -= 1\n\t\t\t\t\tdelete_count += 1\n\t\t\t\telse:\n\t\t\t\t\te /= 2\n\t\t\t\t\tdivide += 1\n\t\t\tdivide_count = max(divide_count, divide)\n\t\treturn delete_count + divide_count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn_op = 0\n\t\tl = len(nums)\n\t\ttarget = l * [0]\n\t\twhile nums != target:\n\t\t\tif all((i % 2 == 0 for i in nums)):\n\t\t\t\tnums = [i / 2 for i in nums]\n\t\t\t\tn_op += 1\n\t\t\telse:\n\t\t\t\tfor i in range(l):\n\t\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\t\tn_op += 1\n\t\treturn n_op\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tma = 0\n\t\tfor n in nums:\n\t\t\tk = 0\n\t\t\twhile n != 0:\n\t\t\t\tif n % 2 == 0:\n\t\t\t\t\tk += 1\n\t\t\t\t\tn = n // 2\n\t\t\t\telse:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tans += 1\n\t\t\t\tma = max(ma, k)\n\t\treturn ans + ma\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\twhile not all((n == 0 for n in nums)):\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n % 2 != 0:\n\t\t\t\t\tnums[i] = n - 1\n\t\t\t\t\tops += 1\n\t\t\tif all((n == 0 for n in nums)):\n\t\t\t\tbreak\n\t\t\tnums = [n // 2 for n in nums]\n\t\t\tops += 1\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tdivied2 = 0\n\t\tres = 0\n\t\tfor i in nums:\n\t\t\ttemp = 0\n\t\t\twhile i > 0:\n\t\t\t\tif i % 2 == 0:\n\t\t\t\t\ti //= 2\n\t\t\t\t\ttemp += 1\n\t\t\t\telse:\n\t\t\t\t\ti -= 1\n\t\t\t\t\tres += 1\n\t\t\t\tdivied2 = max(divied2, temp)\n\t\treturn res + divied2\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tdouble = 0\n\t\tfor i in range(len(nums)):\n\t\t\tcd = 0\n\t\t\twhile nums[i] > 0:\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tcount += 1\n\t\t\t\tcd += 1\n\t\t\t\tnums[i] //= 2\n\t\t\tdouble = max(double, cd)\n\t\treturn count + double - 1\n", "masks = [1431655765, 858993459, 252645135, 16711935, 65535]\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttotOddRem = 0\n\t\tmaxX = nums[0]\n\t\tfor x in nums:\n\t\t\tif x == 1:\n\t\t\t\ttotOddRem += 1\n\t\t\telse:\n\t\t\t\txCopy = x\n\t\t\t\tfor (p, m) in enumerate(masks):\n\t\t\t\t\txCopy = (xCopy & m) + ((xCopy & ~m) >> (1 << p))\n\t\t\t\ttotOddRem += xCopy\n\t\t\tif x > maxX:\n\t\t\t\tmaxX = x\n\t\tleftMost = 0\n\t\tstep = 16\n\t\tfor m in reversed(masks):\n\t\t\tm = ~m\n\t\t\tif m & maxX != 0:\n\t\t\t\tleftMost += step\n\t\t\t\tmaxX &= m\n\t\t\tstep >>= 1\n\t\treturn totOddRem + leftMost\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tonesCount = 0\n\t\taboveOneIdxs = []\n\t\tfor (idx, n) in enumerate(nums):\n\t\t\tif n == 1:\n\t\t\t\tonesCount += 1\n\t\t\telif n > 1:\n\t\t\t\taboveOneIdxs.append(idx)\n\t\twhile onesCount + len(aboveOneIdxs) != 0:\n\t\t\tcount += onesCount\n\t\t\tonesCount = 0\n\t\t\tnewAboveOneIdxs = []\n\t\t\tfor idx in aboveOneIdxs:\n\t\t\t\tif nums[idx] % 2 != 0:\n\t\t\t\t\tnums[idx] -= 1\n\t\t\t\t\tcount += 1\n\t\t\t\tnums[idx] //= 2\n\t\t\t\tif nums[idx] == 1:\n\t\t\t\t\tonesCount += 1\n\t\t\t\telse:\n\t\t\t\t\tnewAboveOneIdxs.append(idx)\n\t\t\tif len(aboveOneIdxs) > 0:\n\t\t\t\tcount += 1\n\t\t\taboveOneIdxs = newAboveOneIdxs\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tnoz = 0\n\t\tnosteps = 0\n\t\twhile noz != n:\n\t\t\tnoz = 0\n\t\t\tnoe = 0\n\t\t\tnoo = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tnoz += 1\n\t\t\t\t\tnoe += 1\n\t\t\t\telif nums[i] % 2 == 0:\n\t\t\t\t\tnoe += 1\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\telse:\n\t\t\t\t\tnoo += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tnosteps += noo\n\t\t\tif noz == n:\n\t\t\t\tbreak\n\t\t\tnosteps += 1\n\t\treturn nosteps - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnum_operations = 0\n\t\todd = True\n\t\teven = False\n\t\twhile odd or even:\n\t\t\tif odd:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tif nums[i] != 0:\n\t\t\t\t\t\tif nums[i] % 2:\n\t\t\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\t\t\tnum_operations += 1\n\t\t\t\t\t\tif nums[i]:\n\t\t\t\t\t\t\teven = True\n\t\t\t\todd = False\n\t\t\tif even:\n\t\t\t\tnum_operations += 1\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] /= 2\n\t\t\t\t\tif nums[i] % 2:\n\t\t\t\t\t\teven = False\n\t\t\t\t\t\todd = True\n\t\treturn num_operations\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\n\t\tdef modify(arr, op, ind):\n\t\t\tif op == 0:\n\t\t\t\tarr[ind] = arr[ind] + 1\n\t\t\tif op == 1:\n\t\t\t\tfor i in range(len(arr)):\n\t\t\t\t\tarr[i] = arr[i] * 2\n\t\t\treturn arr\n\t\tarr = [0] * n\n\t\tops_needed = 0\n\t\tcheck_ind = 0\n\t\tnums.sort(key=lambda x: -x)\n\t\twhile any((n != 0 for n in nums)):\n\t\t\tfor (ind, numb) in enumerate(nums):\n\t\t\t\tif numb >= 1 and numb % 2 == 1:\n\t\t\t\t\tops_needed += 1\n\t\t\t\t\tnums[ind] = nums[ind] - 1\n\t\t\tfor numb in nums:\n\t\t\t\tif numb >= 1 and numb % 2 == 0:\n\t\t\t\t\tops_needed += 1\n\t\t\t\t\tfor (ind, elt) in enumerate(nums):\n\t\t\t\t\t\tnums[ind] = nums[ind] / 2\n\t\t\t\t\tbreak\n\t\t\tcheck_ind += 1\n\t\t\tif check_ind > 100:\n\t\t\t\tbreak\n\t\treturn ops_needed\n", "class Solution:\n\n\tdef makeHalf(self, a):\n\t\tfor i in range(len(a)):\n\t\t\ta[i] //= 2\n\n\tdef makeEven(self, a):\n\t\tc = 0\n\t\tfor i in range(len(a)):\n\t\t\tif a[i] % 2 == 0:\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\ta[i] -= 1\n\t\t\t\tc += 1\n\t\treturn c\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\twhile sum(nums) != 0:\n\t\t\top += self.makeEven(nums)\n\t\t\tif sum(nums) == 0:\n\t\t\t\treturn op\n\t\t\tself.makeHalf(nums)\n\t\t\top += 1\n\t\treturn op\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\twhile sum(nums) != 0:\n\t\t\tcounts = sum([x % 2 == 0 for x in nums])\n\t\t\tif counts == len(nums):\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tres += 1\n\t\t\telse:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tprint(0 % 2)\n\t\tstep = 0\n\t\twhile any((n > 0 for n in nums)):\n\t\t\tif all((n % 2 == 0 for n in nums)):\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\t\t\tstep += 1\n\t\t\telse:\n\t\t\t\tremain_idx = []\n\t\t\t\tfor (i, v) in enumerate(nums):\n\t\t\t\t\tif v % 2 == 1:\n\t\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\t\tdel nums[i]\n\t\t\t\t\t\tstep += 1\n\t\treturn step\n", "class Solution:\n\n\tdef minOperations(self, A: List[int]) -> int:\n\n\t\tdef even(A):\n\t\t\tfor i in range(len(A)):\n\t\t\t\tA[i] //= 2\n\t\t\treturn A\n\n\t\tdef odd(A):\n\t\t\tc = 0\n\t\t\tz = 0\n\t\t\tfor i in range(len(A)):\n\t\t\t\tif A[i] % 2 == 1:\n\t\t\t\t\tA[i] -= 1\n\t\t\t\t\tc += 1\n\t\t\t\t\tif A[i] == 0:\n\t\t\t\t\t\tz += 1\n\t\t\treturn (A, c, z)\n\t\tres = 0\n\t\tzero = 0\n\t\tfor i in A:\n\t\t\tif i == 0:\n\t\t\t\tzero += 1\n\t\twhile zero < len(A):\n\t\t\t(A, c, z) = odd(A)\n\t\t\tzero += z\n\t\t\tres += c\n\t\t\tif zero < len(A):\n\t\t\t\tA = even(A)\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tres = {}\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] != 0:\n\t\t\t\tres[i] = nums[i]\n\t\tzeros = []\n\t\twhile res:\n\t\t\tzeros.clear()\n\t\t\tfor key in res:\n\t\t\t\tif res[key] % 2 != 0:\n\t\t\t\t\tres[key] -= 1\n\t\t\t\t\tcount += 1\n\t\t\t\t\tminus = True\n\t\t\t\tif res[key] == 0:\n\t\t\t\t\tzeros.append(key)\n\t\t\tfor zero in zeros:\n\t\t\t\tres.pop(zero)\n\t\t\tif res:\n\t\t\t\tfor key in res:\n\t\t\t\t\tres[key] //= 2\n\t\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile any(nums):\n\t\t\ttemp = [0] * len(nums)\n\t\t\tflag = False\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tflag = True\n\t\t\t\t\tans += 1\n\t\t\t\telif not flag and (not nums[i] % 2):\n\t\t\t\t\ttemp[i] = nums[i] // 2\n\t\t\tif not flag:\n\t\t\t\tans += 1\n\t\t\t\tnums = temp\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnums.sort(reverse=True)\n\t\ts = sum(nums)\n\t\tres = 0\n\t\twhile s:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\ts = 0\n\t\t\tnums = list([x for x in nums if x > 0])\n\t\t\tif not nums:\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\t\ts += nums[i]\n\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnops = 0\n\t\tall_z = False\n\t\twhile not all_z:\n\t\t\tall_z = True\n\t\t\top2_mark = False\n\t\t\tfor (idx, val) in enumerate(nums):\n\t\t\t\tif val != 0:\n\t\t\t\t\tall_z = False\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\t\t\t\tif val % 2 == 0:\n\t\t\t\t\tif not op2_mark:\n\t\t\t\t\t\tnops += 1\n\t\t\t\t\t\top2_mark = True\n\t\t\t\t\tnums[idx] /= 2\n\t\t\t\telse:\n\t\t\t\t\tnops += 1\n\t\t\t\t\tif nums[idx] - 1 > 0:\n\t\t\t\t\t\tif not op2_mark:\n\t\t\t\t\t\t\tnops += 1\n\t\t\t\t\t\t\top2_mark = True\n\t\t\t\t\tnums[idx] = (nums[idx] - 1) / 2\n\t\treturn nops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tseen_nonzero = True\n\t\twhile True:\n\t\t\tall_zeros = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tans += 1\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tall_zeros = False\n\t\t\tif all_zeros:\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = 0\n\t\twhile True:\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif x & 1:\n\t\t\t\t\tresult += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tif all((x == 0 for x in nums)):\n\t\t\t\treturn result\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tnums[i] //= 2\n\t\t\tresult += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile sum(nums) != 0:\n\t\t\ttmp = nums.copy()\n\t\t\tones_tmp = nums.copy()\n\t\t\tcnt = 0\n\t\t\tones_cnt = 0\n\t\t\tflag = False\n\t\t\tfor (i, a) in enumerate(nums):\n\t\t\t\tif a == 1:\n\t\t\t\t\tones_cnt += 1\n\t\t\t\t\tones_tmp[i] = 0\n\t\t\t\t\tflag = True\n\t\t\t\ttmp[i] = nums[i] // 2\n\t\t\t\tcnt += nums[i] % 2\n\t\t\tif flag:\n\t\t\t\tans += ones_cnt\n\t\t\t\tnums = ones_tmp[:]\n\t\t\telse:\n\t\t\t\tans += cnt + 1\n\t\t\t\tnums = tmp[:]\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\twhile nums != [0] * len(nums):\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\telif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\tif nums == [0] * len(nums):\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tret = 0\n\t\tfor (i, x) in enumerate(nums):\n\t\t\tif x % 2:\n\t\t\t\tret += 1\n\t\t\t\tnums[i] -= 1\n\t\tif all((x == 0 for x in nums)):\n\t\t\treturn ret\n\t\tfor (i, x) in enumerate(nums):\n\t\t\tnums[i] //= 2\n\t\tret += 1\n\t\treturn ret + self.minOperations(nums)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile 1:\n\t\t\tfor (i, vi) in enumerate(nums):\n\t\t\t\tif vi & 1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tnums[i] = vi - 1\n\t\t\tchk = True\n\t\t\tfor (i, vi) in enumerate(nums):\n\t\t\t\tif vi > 0:\n\t\t\t\t\tchk = False\n\t\t\t\tnums[i] = vi // 2\n\t\t\tif chk:\n\t\t\t\tbreak\n\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tzeros = sum([num == 0 for num in nums])\n\t\todds = set([i for i in range(len(nums)) if nums[i] % 2])\n\t\tn = len(nums)\n\t\tcount = 0\n\t\twhile zeros < n:\n\t\t\tif odds:\n\t\t\t\tfor oddidx in odds:\n\t\t\t\t\tnums[oddidx] = nums[oddidx] - 1\n\t\t\t\t\tif nums[oddidx] == 0:\n\t\t\t\t\t\tzeros += 1\n\t\t\t\tcount += len(odds)\n\t\t\t\todds = set()\n\t\t\telse:\n\t\t\t\tfor i in range(n):\n\t\t\t\t\tif nums[i] > 0:\n\t\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\t\tif nums[i] % 2:\n\t\t\t\t\t\t\todds.add(i)\n\t\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(n, res) = (len(nums), 0)\n\t\tmul = [0] * n\n\t\tfor i in range(n):\n\t\t\twhile nums[i] != 0:\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tres += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\telse:\n\t\t\t\t\tmul[i] += 1\n\t\t\t\t\tnums[i] //= 2\n\t\treturn res + max(mul)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tn = len(nums)\n\t\ts = sum(nums)\n\t\twhile s != 0:\n\t\t\tnums_2 = [num % 2 for num in nums]\n\t\t\tdiff = sum(nums_2)\n\t\t\tif diff == 0:\n\t\t\t\tnums = [num // 2 for num in nums]\n\t\t\t\tans += 1\n\t\t\t\ts //= 2\n\t\t\telse:\n\t\t\t\tans += diff\n\t\t\t\ts -= diff\n\t\t\t\tnums = [nums[i] - nums_2[i] for i in range(n)]\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcost = 0\n\t\twhile True:\n\t\t\tall_zeros = True\n\t\t\tall_evens = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tall_zeros = False\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tcost += nums[i] % 2\n\t\t\t\t\tnums[i] = nums[i] - nums[i] % 2\n\t\t\t\t\tall_evens = False\n\t\t\tif all_zeros:\n\t\t\t\tbreak\n\t\t\tif all_evens:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tcost += 1\n\t\treturn cost\n", "class Solution:\n\n\tdef minOperations(self, nums):\n\t\tadd_operations = {}\n\t\tresult = 0\n\t\tmax_m = 0\n\t\tfor i in nums:\n\t\t\tcurrent = i\n\t\t\tif current in add_operations:\n\t\t\t\tresult += add_operations[current]\n\t\t\telse:\n\t\t\t\tadd_amount = 0\n\t\t\t\tmultiplying_amount = 0\n\t\t\t\twhile current:\n\t\t\t\t\tif current % 2:\n\t\t\t\t\t\tadd_amount += 1\n\t\t\t\t\t\tcurrent -= 1\n\t\t\t\t\telse:\n\t\t\t\t\t\tmultiplying_amount += 1\n\t\t\t\t\t\tcurrent = current / 2\n\t\t\t\tmax_m = max(max_m, multiplying_amount)\n\t\t\t\tresult += add_amount\n\t\t\t\tadd_operations[i] = add_amount\n\t\treturn result + max_m\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tmmax = float('inf')\n\t\twhile mmax > 0:\n\t\t\tmmax = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] & 1 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\tmmax = max(mmax, nums[i])\n\t\t\tif mmax > 0:\n\t\t\t\tnums = [x // 2 for x in nums]\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tself.ans = 0\n\t\tself.nums = nums\n\n\t\tdef manipulate():\n\t\t\tfor i in range(len(self.nums)):\n\t\t\t\tif self.nums[i] % 2 == 1:\n\t\t\t\t\tself.ans += 1\n\t\t\t\t\tself.nums[i] -= 1\n\n\t\t\tdef allEven():\n\t\t\t\tfor num in self.nums:\n\t\t\t\t\tif num % 2 == 1:\n\t\t\t\t\t\treturn False\n\t\t\t\treturn True\n\t\t\tif AllZero():\n\t\t\t\treturn\n\t\t\twhile allEven():\n\t\t\t\tself.nums = [num / 2 for num in self.nums]\n\t\t\t\tself.ans += 1\n\n\t\tdef AllZero():\n\t\t\tfor num in self.nums:\n\t\t\t\tif num != 0:\n\t\t\t\t\treturn False\n\t\t\treturn True\n\t\twhile not AllZero():\n\t\t\tmanipulate()\n\t\treturn int(self.ans)\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tm = max(nums)\n\t\tn = math.floor(math.log(m, 2))\n\t\tres = 0\n\t\twhile n >= 1:\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num >= 2 ** n:\n\t\t\t\t\tif num % 2 == 1:\n\t\t\t\t\t\tres += 1\n\t\t\t\t\t\tnums[i] = (nums[i] - 1) / 2\n\t\t\t\t\telse:\n\t\t\t\t\t\tnums[i] = nums[i] / 2\n\t\t\tres += 1\n\t\t\tn = n - 1\n\t\tfor num in nums:\n\t\t\tif num == 1:\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\ttotal = sum(nums)\n\t\twhile total != 0:\n\t\t\tevens = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\t\ttotal -= 1\n\t\t\t\telse:\n\t\t\t\t\tevens += 1\n\t\t\tif evens == len(nums):\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] /= 2\n\t\t\t\t\ttotal -= nums[i]\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef pow2(self, num):\n\t\taddition = 0\n\t\tmult = 0\n\t\twhile num > 0:\n\t\t\tif num % 2 == 0:\n\t\t\t\tnum = num // 2\n\t\t\t\tmult += 1\n\t\t\telse:\n\t\t\t\tnum -= 1\n\t\t\t\taddition += 1\n\t\treturn (mult, addition)\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(result, _) = self.pow2(max(nums))\n\t\tfor num in nums:\n\t\t\tif num > 0:\n\t\t\t\tresult += self.pow2(num)[1]\n\t\treturn result\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tlim = len(nums)\n\t\ttest = [0] * lim\n\t\tt = 0\n\t\twhile nums != test:\n\t\t\tvals = []\n\t\t\tv = 0\n\t\t\tfor i in range(0, lim):\n\t\t\t\tif nums[i] % 2 == 0:\n\t\t\t\t\tvals.append(nums[i] // 2)\n\t\t\t\telse:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tv += 1\n\t\t\tif v == 0:\n\t\t\t\tnums = vals\n\t\t\t\tt += 1\n\t\t\telse:\n\t\t\t\tt += v\n\t\treturn t\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tbig = 0\n\t\tans = 0\n\t\tfor i in range(len(nums)):\n\t\t\ttwos = 0\n\t\t\twhile nums[i] > 0:\n\t\t\t\tif nums[i] % 2 == 0:\n\t\t\t\t\ttwos += 1\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\telse:\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tif twos > big:\n\t\t\t\tbig = twos\n\t\treturn ans + big\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_log = 0\n\t\tcount_zero = 0\n\t\tsteps = 0\n\t\tfor num in nums:\n\t\t\tif num != 0:\n\t\t\t\tlog_num = 0\n\t\t\t\twhile num > 0:\n\t\t\t\t\tif num % 2 == 0:\n\t\t\t\t\t\tnum /= 2\n\t\t\t\t\t\tlog_num += 1\n\t\t\t\t\telse:\n\t\t\t\t\t\tsteps += 1\n\t\t\t\t\t\tnum -= 1\n\t\t\t\tmax_log = max(max_log, log_num)\n\t\treturn steps + max_log\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tpeak = 0\n\t\tfor n in nums:\n\t\t\tans += bin(n)[2:].count('1')\n\t\t\tpeak = max(peak, len(bin(n)[2:]) - 1)\n\t\treturn ans + peak\n", "class Solution:\n\n\tdef minOperations(self, target: List[int]) -> int:\n\t\tresult = 0\n\t\twhile True:\n\t\t\tzero_count = 0\n\t\t\ti = 0\n\t\t\tn = len(target)\n\t\t\twhile i < n:\n\t\t\t\tif target[i] & 1 > 0:\n\t\t\t\t\tbreak\n\t\t\t\telif target[i] == 0:\n\t\t\t\t\tzero_count += 1\n\t\t\t\ti += 1\n\t\t\tif zero_count == n:\n\t\t\t\treturn result\n\t\t\tif i == n:\n\t\t\t\tfor j in range(n):\n\t\t\t\t\ttarget[j] = target[j] // 2\n\t\t\t\tresult += 1\n\t\t\tfor j in range(i, n):\n\t\t\t\tif target[j] & 1:\n\t\t\t\t\ttarget[j] -= 1\n\t\t\t\t\tresult += 1\n", "class Solution:\n\n\tdef minOperations(self, A: List[int]) -> int:\n\t\tif all((v == 0 for v in A)):\n\t\t\treturn 0\n\t\tcurr = 0\n\t\tA_next = A.copy()\n\t\tchanged = False\n\t\tfor (i, v) in enumerate(A):\n\t\t\tif v % 2 == 1:\n\t\t\t\tchanged = True\n\t\t\t\tcurr += 1\n\t\t\t\tA_next[i] = v - 1\n\t\tif not changed:\n\t\t\treturn 1 + self.minOperations([v // 2 for v in A])\n\t\telse:\n\t\t\treturn curr + self.minOperations(A_next)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tmoves = 0\n\t\twhile True:\n\t\t\tzeros = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tmoves += 1\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tzeros += 1\n\t\t\tif zeros == n:\n\t\t\t\treturn moves\n\t\t\tfor j in range(n):\n\t\t\t\tnums[j] //= 2\n\t\t\tmoves += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt = 0\n\t\twhile any(nums):\n\t\t\teven = 0\n\t\t\tfor (k, v) in enumerate(nums):\n\t\t\t\tif v % 2 == 1:\n\t\t\t\t\tcnt += 1\n\t\t\t\t\tnums[k] -= 1\n\t\t\t\telif v > 0:\n\t\t\t\t\teven += 1\n\t\t\tif even > 0:\n\t\t\t\tnums = list([x // 2 for x in nums])\n\t\t\t\tcnt += 1\n\t\treturn cnt\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tself.count = 0\n\n\t\tdef sub(nums):\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tself.count += 1\n\t\t\treturn nums\n\n\t\tdef divide_all(nums):\n\t\t\tfor k in range(len(nums)):\n\t\t\t\tif nums[k] == 0 or nums[k] % 2 == 0:\n\t\t\t\t\tnums[k] //= 2\n\t\t\t\telse:\n\t\t\t\t\treturn []\n\t\t\treturn nums\n\n\t\tdef zeros(nums):\n\t\t\tc = 0\n\t\t\tfor n in nums:\n\t\t\t\tif n == 0:\n\t\t\t\t\tc += 1\n\t\t\treturn c\n\t\tsub(nums)\n\t\twhile zeros(nums) < len(nums):\n\t\t\tdivide_all(nums)\n\t\t\tself.count += 1\n\t\t\tsub(nums)\n\t\treturn self.count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef check(nums):\n\t\t\tflag = False\n\t\t\tfor n in nums:\n\t\t\t\tif n > 1:\n\t\t\t\t\tflag = True\n\t\t\treturn flag\n\t\tcnt = 0\n\t\tn = len(nums)\n\t\tflag = check(nums)\n\t\twhile flag:\n\t\t\tcnt += 1\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\tcnt += 1\n\t\t\t\telse:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tflag = check(nums)\n\t\tfor n in nums:\n\t\t\tif n != 0:\n\t\t\t\tcnt += 1\n\t\treturn cnt\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnums.sort()\n\t\tn = len(nums)\n\t\tq = collections.deque()\n\t\tq += [(0, nums)]\n\t\ttot = [0] * n\n\t\twhile q:\n\t\t\t(cnt, t) = q.popleft()\n\t\t\tif t == tot:\n\t\t\t\treturn cnt\n\t\t\tflag = False\n\t\t\tfor i in range(n):\n\t\t\t\tif t[i] % 2:\n\t\t\t\t\tcnt += 1\n\t\t\t\t\tt[i] -= 1\n\t\t\t\tif t[i] != 0:\n\t\t\t\t\tflag = True\n\t\t\t\tt[i] //= 2\n\t\t\tif flag:\n\t\t\t\tcnt += 1\n\t\t\tq += [(cnt, t)]\n\t\treturn 0\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tplus = 0\n\t\tdouble = 0\n\t\tfor x in nums:\n\t\t\tif x != 0:\n\t\t\t\tplus += 1\n\t\t\tcounter = 0\n\t\t\twhile x / 2 >= 1:\n\t\t\t\tif x % 2 != 0 and x != 1:\n\t\t\t\t\tplus += 1\n\t\t\t\t\tx -= 1\n\t\t\t\tx /= 2\n\t\t\t\tcounter += 1\n\t\t\tdouble = max(double, counter)\n\t\treturn plus + double\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tm = 0\n\t\tnumb = len(nums)\n\t\twhile True:\n\t\t\tzc = 0\n\t\t\tvar = 0\n\t\t\tfor i in range(numb):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\t\tm += 1\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tzc += 1\n\t\t\tif zc == numb:\n\t\t\t\tbreak\n\t\t\tnums = list([i // 2 for i in nums])\n\t\t\tm += 1\n\t\treturn m\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcounter = 0\n\t\twhile 1:\n\t\t\ttemp_counter = 0\n\t\t\tbigger_than_zero = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\ttemp_counter += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tbigger_than_zero += 1\n\t\t\t\t\ttemp = bin(nums[i])\n\t\t\tcounter += temp_counter\n\t\t\tif bigger_than_zero == 0:\n\t\t\t\treturn counter\n\t\t\trun_again = True\n\t\t\twhile run_again:\n\t\t\t\tcounter += 1\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\t\trun_again = False\n\t\treturn counter\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tself.count = 0\n\t\tall_even = False\n\n\t\tdef reduce():\n\t\t\tnonlocal all_even\n\t\t\tzero = 0\n\t\t\tif all_even:\n\t\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\t\tnums[i] >>= 1\n\t\t\t\t\tif nums[i] & 1:\n\t\t\t\t\t\tall_even = False\n\t\t\t\t\tzero += num == 0\n\t\t\t\tself.count += 1\n\t\t\telse:\n\t\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\t\tif num & 1:\n\t\t\t\t\t\tself.count += 1\n\t\t\t\t\t\tnums[i] -= 1\n\t\t\t\tall_even = True\n\t\t\treturn zero\n\t\twhile True:\n\t\t\tn = reduce()\n\t\t\tif n == len(nums):\n\t\t\t\tbreak\n\t\treturn self.count - 1\n", "from collections import deque\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tstack = deque([[nums, 0]])\n\t\twhile stack:\n\t\t\t(cur_nums, count) = stack.popleft()\n\t\t\tif all([n == 0 or n == 1 for n in cur_nums]):\n\t\t\t\treturn sum(cur_nums) + count\n\t\t\tif all([n % 2 == 0 for n in cur_nums]):\n\t\t\t\tstack.append([[n // 2 for n in cur_nums], count + 1])\n\t\t\t\tcontinue\n\t\t\ttmp = []\n\t\t\tfor n in cur_nums:\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\ttmp.append(n - 1)\n\t\t\t\telse:\n\t\t\t\t\ttmp.append(n)\n\t\t\tstack.append([tmp, count])\n", "class Solution:\n\n\tdef minOperations(self, nums, op=0):\n\t\tisum = 0\n\t\te = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 != 0:\n\t\t\t\top = op + 1\n\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\te = 1\n\t\t\t\t\tnums[i] = nums[i] / 2\n\t\t\telif nums[i] != 0:\n\t\t\t\te = 1\n\t\t\t\tnums[i] = nums[i] / 2\n\t\t\tisum = isum + nums[i]\n\t\top = op + e\n\t\tif isum == 0:\n\t\t\treturn op\n\t\treturn self.minOperations(nums, op)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile True:\n\t\t\tmaxv = 0\n\t\t\tfor k in range(len(nums)):\n\t\t\t\tif nums[k] % 2:\n\t\t\t\t\tnums[k] -= 1\n\t\t\t\t\tans += 1\n\t\t\t\tmaxv = max(maxv, nums[k])\n\t\t\tif maxv == 0:\n\t\t\t\tbreak\n\t\t\tif maxv > 0:\n\t\t\t\tfor k in range(len(nums)):\n\t\t\t\t\tnums[k] //= 2\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(res, n) = (0, len(nums))\n\t\tfor i in range(32):\n\t\t\t(zero, one) = (0, 0)\n\t\t\tfor j in range(n):\n\t\t\t\tif nums[j] & 1 == 1:\n\t\t\t\t\tone += 1\n\t\t\t\tnums[j] >>= 1\n\t\t\t\tif nums[j] == 0:\n\t\t\t\t\tzero += 1\n\t\t\tres += one\n\t\t\tif zero == n:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tres = 0\n\t\tmax_zero = 0\n\t\tfor i in range(len(nums)):\n\t\t\t(zero, one) = Solution.parse(nums[i])\n\t\t\tres += one\n\t\t\tmax_zero = max(max_zero, zero)\n\t\tres += max_zero\n\t\treturn res\n\n\tdef parse(v):\n\t\t(zero, one) = (0, 0)\n\t\twhile v > 0:\n\t\t\tif v % 2 == 1:\n\t\t\t\tone += 1\n\t\t\t\tv -= 1\n\t\t\telse:\n\t\t\t\tzero += 1\n\t\t\t\tv /= 2\n\t\treturn (zero, one)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\twhile True:\n\t\t\tdivide = False\n\t\t\tall_zero = True\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tall_zero = False\n\t\t\t\tif n > 1:\n\t\t\t\t\tdivide = True\n\t\t\t\tres += n % 2\n\t\t\t\tnums[i] //= 2\n\t\t\tres += int(divide)\n\t\t\tif all_zero:\n\t\t\t\tbreak\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif not nums or sum(nums) == 0:\n\t\t\treturn 0\n\t\tcnt = 0\n\t\twhile sum(nums) != 0:\n\t\t\tif all((num % 2 == 0 for num in nums)):\n\t\t\t\tcnt += 1\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] //= 2\n\t\t\telse:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tif nums[i] % 2:\n\t\t\t\t\t\tcnt += 1\n\t\t\t\t\t\tnums[i] -= 1\n\t\treturn cnt\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile True:\n\t\t\ts = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnum = nums[i]\n\t\t\t\tif num & 1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tnums[i] = num - 1\n\t\t\t\t\ts += num - 1\n\t\t\t\telse:\n\t\t\t\t\ts += num\n\t\t\tif s == 0:\n\t\t\t\treturn count\n\t\t\tnums = [num // 2 for num in nums]\n\t\t\tcount += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tnum_zero = sum((n == 0 for n in nums))\n\t\twhile num_zero != len(nums):\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tnum_zero += 1\n\t\t\t\tnums[i] >>= 1\n\t\t\tans += 1\n\t\treturn ans - 1\n\n\tdef num_steps(self, n):\n\t\tif n == 0:\n\t\t\treturn 0\n\t\t(steps, mask) = (0, 1)\n\t\twhile mask <= n:\n\t\t\tif n & mask:\n\t\t\t\tsteps += 2\n\t\t\telse:\n\t\t\t\tsteps += 1\n\t\t\tmask <<= 1\n\t\treturn steps - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnumreps = []\n\t\tfor num in nums:\n\t\t\tnumreps.append(self.numToOps(num))\n\t\tnumops = 0\n\t\tmax2s = 0\n\t\tfor rep in numreps:\n\t\t\tnumops += rep[1]\n\t\t\tif rep[2] > max2s:\n\t\t\t\tmax2s = rep[2]\n\t\treturn numops + max2s\n\n\tdef numToOps(self, val):\n\t\trep = {1: 0, 2: 0}\n\t\twhile val:\n\t\t\tif val % 2:\n\t\t\t\trep[1] += 1\n\t\t\t\tval = val - 1\n\t\t\telse:\n\t\t\t\trep[2] += 1\n\t\t\t\tval = int(val / 2)\n\t\treturn rep\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tadds = []\n\t\tmuls = []\n\t\tfor (idx, num) in enumerate(nums):\n\t\t\tadds.append(0)\n\t\t\tmuls.append(0)\n\t\t\twhile num > 0:\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tadds[idx] += 1\n\t\t\t\t\tnum -= 1\n\t\t\t\telse:\n\t\t\t\t\tmuls[idx] += 1\n\t\t\t\t\tnum /= 2\n\t\treturn sum(adds) + max(muls)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmaxval = max(nums)\n\t\tidx = nums.index(maxval)\n\t\tans = 0\n\t\twhile nums[idx] != 0:\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tans += n % 2\n\t\t\t\tnums[i] = n - n % 2\n\t\t\tif nums[idx] != 0:\n\t\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif not nums:\n\t\t\treturn 0\n\t\tn = len(nums)\n\t\tans = 0\n\t\twhile True:\n\t\t\tzero_count = 0\n\t\t\ti = 0\n\t\t\twhile i < n:\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tbreak\n\t\t\t\telif nums[i] == 0:\n\t\t\t\t\tzero_count += 1\n\t\t\t\ti += 1\n\t\t\tif zero_count == n:\n\t\t\t\treturn ans\n\t\t\tif i == n:\n\t\t\t\tfor j in range(n):\n\t\t\t\t\tnums[j] //= 2\n\t\t\t\tans += 1\n\t\t\tfor j in range(i, n):\n\t\t\t\tif nums[j] % 2 == 1:\n\t\t\t\t\tnums[j] -= 1\n\t\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tN = len(nums)\n\t\tref = [0] * N\n\t\tres = 0\n\t\twhile nums != ref:\n\t\t\tisAllEven = 1\n\t\t\tfor i in range(N):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\t\tisAllEven = 0\n\t\t\tif isAllEven:\n\t\t\t\tfor i in range(N):\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\tres += 1\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\todd = 0\n\t\tflag = True\n\t\twhile len(nums) > 0:\n\t\t\ttemp = []\n\t\t\tif flag:\n\t\t\t\tfor x in nums:\n\t\t\t\t\tif x & 1 == 1:\n\t\t\t\t\t\tres += 1\n\t\t\t\t\t\tif x - 1 != 0:\n\t\t\t\t\t\t\ttemp.append(x - 1)\n\t\t\t\t\telif x != 0:\n\t\t\t\t\t\ttemp.append(x)\n\t\t\t\tflag = False\n\t\t\telse:\n\t\t\t\tfor x in nums:\n\t\t\t\t\ttemp.append(x // 2)\n\t\t\t\tres += 1\n\t\t\t\tflag = True\n\t\t\tnums = temp\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tcalls = 0\n\t\twhile True:\n\t\t\tnum_zeros = 0\n\t\t\todd_index = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tbreak\n\t\t\t\telif nums[i] == 0:\n\t\t\t\t\tnum_zeros += 1\n\t\t\t\todd_index += 1\n\t\t\tif num_zeros == n:\n\t\t\t\treturn calls\n\t\t\tif odd_index == n:\n\t\t\t\tfor j in range(n):\n\t\t\t\t\tnums[j] /= 2\n\t\t\t\tcalls += 1\n\t\t\tfor j in range(i, n):\n\t\t\t\tif nums[j] % 2 != 0:\n\t\t\t\t\tnums[j] -= 1\n\t\t\t\t\tcalls += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\ts2 = []\n\t\tfor i in nums:\n\t\t\tn1 = 0\n\t\t\tm = 0\n\t\t\tfor j in range(32):\n\t\t\t\tif i & 2 ** j != 0:\n\t\t\t\t\tm = j\n\t\t\t\t\tn1 += 1\n\t\t\tans += n1\n\t\t\ts2.append(m)\n\t\ts2.sort()\n\t\tans += s2[0]\n\t\tfor i in range(1, len(s2)):\n\t\t\tans += s2[i] - s2[i - 1]\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttotal = 0\n\t\tmax_divide = 0\n\t\tfor (i, x) in enumerate(nums):\n\t\t\tdivide = 0\n\t\t\twhile x > 0:\n\t\t\t\tif x % 2 == 1:\n\t\t\t\t\tx -= 1\n\t\t\t\t\ttotal += 1\n\t\t\t\telse:\n\t\t\t\t\tx /= 2\n\t\t\t\t\tdivide += 1\n\t\t\tif divide > max_divide:\n\t\t\t\tmax_divide = divide\n\t\treturn total + max_divide\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile sum(nums) > 0:\n\t\t\tcan_divide = False\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tcan_divide = True\n\t\t\tif can_divide:\n\t\t\t\tans += 1\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] //= 2\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = {}\n\n\t\tdef iseven(n):\n\t\t\treturn n % 2 == 0\n\t\tans = 0\n\t\tfor n in nums:\n\t\t\tcount[n] = count.get(n, 0) + 1\n\t\tkeys = list(count.keys())\n\t\tfor n in keys:\n\t\t\tif n == 0:\n\t\t\t\tcount.pop(n)\n\t\t\tif not iseven(n):\n\t\t\t\tans += count[n]\n\t\t\t\tn -= 1\n\t\t\t\tif n != 0:\n\t\t\t\t\tcount[n] = count.get(n, 0) + count[n + 1]\n\t\t\t\tcount.pop(n + 1)\n\t\twhile len(count) > 0:\n\t\t\tkeys = list(count.keys())\n\t\t\tans += 1\n\t\t\tnew_count = {}\n\t\t\tfor n in keys:\n\t\t\t\tif not iseven(int(n / 2)):\n\t\t\t\t\tif int(n / 2) != 1:\n\t\t\t\t\t\tnew_count[int(n / 2) - 1] = new_count.get(int(n / 2) - 1, 0) + count[n]\n\t\t\t\t\tans += count[n]\n\t\t\t\telse:\n\t\t\t\t\tnew_count[int(n / 2)] = new_count.get(int(n / 2), 0) + count[n]\n\t\t\tcount = new_count\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\n\t\tdef op0() -> int:\n\t\t\tnonlocal nums\n\t\t\tops = sum([n % 2 for n in nums])\n\t\t\tnums = [n >> 1 << 1 for n in nums]\n\t\t\treturn ops\n\n\t\tdef op1() -> int:\n\t\t\tnonlocal nums\n\t\t\tops = 0\n\t\t\twhile sum([n % 2 for n in nums]) == 0:\n\t\t\t\tops += 1\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\t\treturn ops\n\t\twhile sum(nums):\n\t\t\tops += op0()\n\t\t\tif sum(nums):\n\t\t\t\tops += op1()\n\t\treturn ops\n", "def adjust2power(n):\n\tif n == 0:\n\t\treturn 0\n\tfor i in range(1, n + 1):\n\t\tif 1 << i >= n:\n\t\t\tif n % (1 << i) != 0:\n\t\t\t\ti -= 1\n\t\t\tbreak\n\treturn 1 << i\n\ndef howManyPower(n):\n\tfor i in range(1, n + 1):\n\t\tif 1 << i == n:\n\t\t\treturn i\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnums2p = []\n\t\tans = 0\n\t\twhile max(nums) > 1:\n\t\t\tans += 1\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tif nums[i] > 1:\n\t\t\t\t\tans += nums[i] % 2\n\t\t\t\tnums[i] = max(nums[i] // 2, 1)\n\t\treturn ans + len(nums) - nums.count(0)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tn = len(nums)\n\t\twhile True:\n\t\t\tok = False\n\t\t\tflag = True\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\tif nums[i] != 0 and (not nums[i] & 1):\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\t\tif flag:\n\t\t\t\t\t\tans += 1\n\t\t\t\t\t\tflag = False\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tok = True\n\t\t\tif not ok:\n\t\t\t\tbreak\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tret = 0\n\t\tchange = 0\n\t\twhile sum(nums):\n\t\t\tchange = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tret += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tchange = 1\n\t\t\tif change == 0:\n\t\t\t\tret += 1\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\treturn ret\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tf = {}\n\n\t\tdef calc(x):\n\t\t\tif x == 0:\n\t\t\t\treturn (0, 0)\n\t\t\tif x not in f:\n\t\t\t\tif x % 2 == 1:\n\t\t\t\t\t(a, b) = calc(x - 1)\n\t\t\t\t\tf[x] = (a + 1, b)\n\t\t\t\telse:\n\t\t\t\t\t(a, b) = calc(x // 2)\n\t\t\t\t\tf[x] = (a, b + 1)\n\t\t\treturn f[x]\n\t\tx = []\n\t\ty = []\n\t\tfor e in nums:\n\t\t\t(a, b) = calc(e)\n\t\t\tx.append(a)\n\t\t\ty.append(b)\n\t\treturn sum(x) + max(y)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tdone = [0] * n\n\t\tans = 0\n\t\twhile nums != done:\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif x % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tans += 1\n\t\t\tif nums != done:\n\t\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\t\tnums[i] /= 2\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, a: List[int]) -> int:\n\t\tres = [0]\n\t\twhile True:\n\t\t\tself.checkOdd(a, res)\n\t\t\tend = self.checkDivide(a)\n\t\t\tif end:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tres[0] += 1\n\t\treturn res[0]\n\n\tdef checkOdd(self, a, res):\n\t\tfor i in range(len(a)):\n\t\t\tif a[i] % 2 != 0:\n\t\t\t\ta[i] -= 1\n\t\t\t\tres[0] += 1\n\n\tdef checkDivide(self, a):\n\t\tflg = True\n\t\tfor i in range(len(a)):\n\t\t\tif a[i] > 0:\n\t\t\t\ta[i] /= 2\n\t\t\t\tflg = False\n\t\treturn flg\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile True:\n\t\t\top = False\n\t\t\tzeroes = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tzeroes += 1\n\t\t\t\telse:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\top = True\n\t\t\tif op:\n\t\t\t\tcount += 1\n\t\t\tif zeroes == len(nums):\n\t\t\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = 0\n\t\twhile True:\n\t\t\tallzero = True\n\t\t\tfor (index, num) in enumerate(nums):\n\t\t\t\tif num != 0:\n\t\t\t\t\tallzero = False\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\tnums[index] = num - 1\n\t\t\t\t\tresult += 1\n\t\t\tif allzero:\n\t\t\t\tbreak\n\t\t\tallzero = True\n\t\t\tfor (index, num) in enumerate(nums):\n\t\t\t\tif num != 0:\n\t\t\t\t\tallzero = False\n\t\t\t\tnums[index] = num // 2\n\t\t\tif allzero:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tresult += 1\n\t\treturn result\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnum_operations = 0\n\t\tstacks = [[], []]\n\t\tcur_idx = 0\n\t\tnxt_idx = 1\n\t\todd = False\n\t\tfor num in nums:\n\t\t\tif num % 2:\n\t\t\t\todd = True\n\t\t\tif num:\n\t\t\t\tstacks[0].append(num)\n\t\tnum_operations = 0\n\t\twhile stacks[0] or stacks[1]:\n\t\t\tif odd:\n\t\t\t\twhile stacks[cur_idx]:\n\t\t\t\t\tnxt = stacks[cur_idx].pop()\n\t\t\t\t\tif nxt % 2:\n\t\t\t\t\t\tnxt -= 1\n\t\t\t\t\t\tnum_operations += 1\n\t\t\t\t\tif nxt:\n\t\t\t\t\t\tstacks[nxt_idx].append(nxt)\n\t\t\t\todd = False\n\t\t\telse:\n\t\t\t\tnum_operations += 1\n\t\t\t\twhile stacks[cur_idx]:\n\t\t\t\t\tnxt = stacks[cur_idx].pop()\n\t\t\t\t\tnxt /= 2\n\t\t\t\t\tif nxt % 2:\n\t\t\t\t\t\todd = True\n\t\t\t\t\tif nxt:\n\t\t\t\t\t\tstacks[nxt_idx].append(nxt)\n\t\t\t(cur_idx, nxt_idx) = (nxt_idx, cur_idx)\n\t\treturn num_operations\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef proc(nums):\n\t\t\tcnt = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 > 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcnt += 1\n\t\t\tif cnt == 0:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] //= 2\n\t\t\treturn max(cnt, 1)\n\t\tops = 0\n\t\twhile sum(nums) > 0:\n\t\t\tops += proc(nums)\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tm = max(nums)\n\t\tn = nums.count(m)\n\t\treturn sum((bin(a).count('1') for a in nums)) + len(bin(max(nums))) - 3\n", "class Solution:\n\n\tdef minOperations(self, nums) -> int:\n\t\tsteps = 0\n\t\twhile True:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tsteps += 1\n\t\t\tremaining = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tremaining += 1\n\t\t\tif remaining == 0:\n\t\t\t\treturn steps\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] /= 2\n\t\t\tsteps += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tl = len(nums)\n\t\twhile True:\n\t\t\tallZeros = True\n\t\t\tfor i in range(l):\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tallZeros = False\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tif allZeros:\n\t\t\t\treturn count\n\t\t\tflag = False\n\t\t\tfor i in range(l):\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tflag = True\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tif flag:\n\t\t\t\tcount += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = 0\n\t\twhile nums:\n\t\t\tnew = []\n\t\t\tfor x in nums:\n\t\t\t\tif x > 0:\n\t\t\t\t\tif x != 1:\n\t\t\t\t\t\tnew.append(x - (x & 1))\n\t\t\t\t\tresult += x & 1\n\t\t\tnums = new\n\t\t\tif not nums:\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\tresult += 1\n\t\treturn result\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tret = 0\n\n\t\tdef check(nums):\n\t\t\tisAllZero = 1\n\t\t\tmultiplied = 0\n\t\t\tres = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tisAllZero = 0\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tres += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\tif nums[i] != 0:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\tmultiplied = 1\n\t\t\tif multiplied == 1:\n\t\t\t\tres += 1\n\t\t\treturn (isAllZero, res)\n\t\twhile True:\n\t\t\t(done, cnt) = check(nums)\n\t\t\tret += cnt\n\t\t\tif done == 1:\n\t\t\t\tbreak\n\t\treturn ret\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ts = set(nums)\n\t\tif len(s) == 1 and 0 in s:\n\t\t\treturn 0\n\t\telse:\n\t\t\tl = nums\n\t\t\tcnt = 0\n\t\t\tfor i in range(len(l)):\n\t\t\t\tif l[i] % 2 == 1:\n\t\t\t\t\tcnt += 1\n\t\t\t\t\tl[i] -= 1\n\t\t\tif cnt == 0:\n\t\t\t\treturn 1 + self.minOperations([a // 2 for a in l])\n\t\t\telse:\n\t\t\t\treturn cnt + self.minOperations(l)\n", "import math\n\nclass Solution:\n\n\tdef minOperations(self, n: List[int]) -> int:\n\t\tnums = []\n\t\tfor i in range(len(n)):\n\t\t\tif n[i] == 0:\n\t\t\t\tcontinue\n\t\t\tnums.append(n[i])\n\n\t\tdef countOdd(nums):\n\t\t\tc = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] != 1 and nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tc += 1\n\t\t\treturn c\n\t\tcount = 0\n\t\twhile set(nums) != {1}:\n\t\t\tcount += countOdd(nums)\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 1:\n\t\t\t\t\tcontinue\n\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tcount += 1\n\t\tcount += len(nums)\n\t\treturn count\n", "class Solution:\n\n\tdef is_divisible(self, nums):\n\t\tres = []\n\t\tfor ix in range(len(nums)):\n\t\t\tif nums[ix] % 2 != 0:\n\t\t\t\tres.append(ix)\n\t\treturn res\n\n\tdef divide_by_2(self, nums):\n\t\tfor ix in range(len(nums)):\n\t\t\tnums[ix] = nums[ix] / 2\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\twhile nums != [0] * len(nums):\n\t\t\tminus_ix = self.is_divisible(nums)\n\t\t\tfor ix in minus_ix:\n\t\t\t\tnums[ix] -= 1\n\t\t\t\tops += 1\n\t\t\tif nums == [0] * len(nums):\n\t\t\t\treturn ops\n\t\t\tself.divide_by_2(nums)\n\t\t\tops += 1\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\thigh = len(bin(max(nums))) - 3\n\t\tone = sum([bin(n).count('1') for n in nums])\n\t\treturn high + one\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\ttemp = c = 0\n\t\twhile True:\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] == 1:\n\t\t\t\t\tc += 1\n\t\t\t\t\tnums[i] = 0\n\t\t\t\telif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tc += 1\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\ttemp += 1\n\t\t\tif temp == n:\n\t\t\t\treturn c\n\t\t\ttemp = 0\n\t\t\tfor i in range(n):\n\t\t\t\tnums[i] = int(nums[i] / 2)\n\t\t\tc += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef nrOfOpsToZero(n):\n\t\t\tif n == 0:\n\t\t\t\treturn (0, 0)\n\t\t\tif n % 2 == 1:\n\t\t\t\t(recDups, recIncs) = nrOfOpsToZero(n - 1)\n\t\t\t\treturn (recDups, recIncs + 1)\n\t\t\t(recDups, recIncs) = nrOfOpsToZero(n // 2)\n\t\t\treturn (recDups + 1, recIncs)\n\t\tmaxDups = 0\n\t\ttotalIncs = 0\n\t\tfor i in range(0, len(nums)):\n\t\t\t(dups, incs) = nrOfOpsToZero(nums[i])\n\t\t\ttotalIncs += incs\n\t\t\tmaxDups = max(maxDups, dups)\n\t\treturn int(maxDups + totalIncs)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef makeeven():\n\t\t\tdid = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tdid += 1\n\t\t\treturn did\n\n\t\tdef halv():\n\t\t\tdid = False\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i]:\n\t\t\t\t\tnums[i] >>= 1\n\t\t\t\t\tdid = True\n\t\t\treturn did\n\t\tcount = 0\n\t\twhile any(nums):\n\t\t\tcount += makeeven()\n\t\t\tcount += int(halv())\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(odds, even) = ([], [])\n\t\tfor i in nums:\n\t\t\tif i & 1:\n\t\t\t\todds.append(i)\n\t\t\telif i != 0:\n\t\t\t\teven.append(i)\n\t\tcount = 0\n\t\twhile odds or even:\n\t\t\tif odds:\n\t\t\t\ti = odds.pop()\n\t\t\t\tif i - 1 != 0:\n\t\t\t\t\teven.append(i - 1)\n\t\t\telse:\n\t\t\t\tnew_even = []\n\t\t\t\tfor i in even:\n\t\t\t\t\ti //= 2\n\t\t\t\t\tif i & 1:\n\t\t\t\t\t\todds.append(i)\n\t\t\t\t\telse:\n\t\t\t\t\t\tnew_even.append(i)\n\t\t\t\teven = new_even\n\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\t@lru_cache(None)\n\t\tdef steps(n):\n\t\t\tif n == 0:\n\t\t\t\treturn (0, 0, 0)\n\t\t\tif n == 1:\n\t\t\t\treturn (1, 1, 0)\n\t\t\tif n & 1:\n\t\t\t\t(a, b, c) = steps(n - 1)\n\t\t\t\treturn (a + 1, b + 1, c)\n\t\t\t(a, b, c) = steps(n // 2)\n\t\t\treturn (a + 1, b, c + 1)\n\t\tevens = 0\n\t\todds = 0\n\t\tfor num in nums:\n\t\t\t(a, b, c) = steps(num)\n\t\t\todds += b\n\t\t\tevens = max(evens, c)\n\t\treturn odds + evens\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tlength = len(nums)\n\n\t\tdef check_all_zeros(arr):\n\t\t\tfor ele in arr:\n\t\t\t\tif ele != 0:\n\t\t\t\t\treturn False\n\t\t\treturn True\n\n\t\tdef divide_by_2(arr):\n\t\t\treturn list([x / 2 for x in arr])\n\t\tops = 0\n\t\twhile True:\n\t\t\tif check_all_zeros(nums):\n\t\t\t\treturn ops\n\t\t\tall_even = True\n\t\t\tfor i in range(length):\n\t\t\t\tnum = nums[i]\n\t\t\t\tif num % 2 == 0:\n\t\t\t\t\tif i == length - 1 and all_even:\n\t\t\t\t\t\tnums = divide_by_2(nums)\n\t\t\t\t\t\tops += 1\n\t\t\t\telse:\n\t\t\t\t\tall_even = False\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tops += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tn = len(nums)\n\t\twhile True:\n\t\t\tp = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tres += 1\n\t\t\t\tp += nums[i]\n\t\t\tif p == 0:\n\t\t\t\treturn res\n\t\t\tfor i in range(n):\n\t\t\t\tnums[i] //= 2\n\t\t\tres += 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tn = len(nums)\n\t\tco = 0\n\t\twhile True:\n\t\t\tco = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tans += 1\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tco += 1\n\t\t\tif co == n:\n\t\t\t\treturn ans\n\t\t\tfor i in range(n):\n\t\t\t\tnums[i] = nums[i] // 2\n\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, A: List[int]) -> int:\n\t\tif all((v == 0 for v in A)):\n\t\t\treturn 0\n\t\todds = 0\n\t\tA_next = A.copy()\n\t\tfor (i, v) in enumerate(A):\n\t\t\tif v % 2 == 1:\n\t\t\t\todds += 1\n\t\t\t\tA_next[i] = v - 1\n\t\tif odds > 0:\n\t\t\treturn odds + self.minOperations(A_next)\n\t\treturn 1 + self.minOperations([v // 2 for v in A])\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\twhile max(nums) != 0:\n\t\t\tallEven = True\n\t\t\tfor (i, n) in enumerate(nums):\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\top += 1\n\t\t\t\t\tallEven = False\n\t\t\tif allEven:\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\t\t\top += 1\n\t\treturn op\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tc = 0\n\t\twhile len(nums) != 0:\n\t\t\tL = []\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 1:\n\t\t\t\t\tc += 1\n\t\t\t\telif nums[i] % 2 == 1:\n\t\t\t\t\tL.append(nums[i] // 2)\n\t\t\t\t\tc += 1\n\t\t\t\telif nums[i] != 0 and nums[i] % 2 == 0:\n\t\t\t\t\tL.append(nums[i] // 2)\n\t\t\tif len(L) != 0:\n\t\t\t\tc += 1\n\t\t\tnums = L\n\t\treturn c\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile set(nums) != {0}:\n\t\t\teven = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tans += 1\n\t\t\t\t\teven = False\n\t\t\t\t\tnums[i] -= 1\n\t\t\tif even:\n\t\t\t\tnums = [i // 2 for i in nums]\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tc = 0\n\t\tn = len(nums)\n\t\twhile True:\n\t\t\tif len(set(nums)) == 1 and nums[0] == 0:\n\t\t\t\tbreak\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 != 0 and nums[i] > 0 and (nums[i] != 0):\n\t\t\t\t\tnums[i] = nums[i] - 1\n\t\t\t\t\tc += 1\n\t\t\tf = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 == 0:\n\t\t\t\t\tf += 1\n\t\t\tif len(set(nums)) == 1 and nums[0] == 0:\n\t\t\t\tbreak\n\t\t\tif f == len(nums):\n\t\t\t\tfor i in range(n):\n\t\t\t\t\tif nums[i] % 2 == 0 and nums[i] != 0:\n\t\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tc += 1\n\t\treturn c\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top = 0\n\t\twhile sum(nums) != 0:\n\t\t\todds = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] & 1 != 0:\n\t\t\t\t\todds += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\tif odds == 0:\n\t\t\t\tnums = list(map(lambda x: x // 2, nums))\n\t\t\t\top += 1\n\t\t\telse:\n\t\t\t\top += odds\n\t\treturn op\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif sum(nums) == 0:\n\t\t\treturn 0\n\t\ttotal = 0\n\t\tzeros = False\n\t\twhile sum(nums) > 0:\n\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\tif num < 1:\n\t\t\t\t\tcontinue\n\t\t\t\tzeros = False\n\t\t\t\ttotal += num % 2\n\t\t\t\tnums[i] -= num % 2\n\t\t\tif sum(nums) > 0:\n\t\t\t\ttotal += 1\n\t\t\t\tfor (i, num) in enumerate(nums):\n\t\t\t\t\tnums[i] >>= 1\n\t\treturn total\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tif sum(nums) == 0:\n\t\t\treturn 0\n\t\ts = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 == 1:\n\t\t\t\tnums[i] -= 1\n\t\t\t\ts += 1\n\t\tif s == 0:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] //= 2\n\t\t\ts += 1\n\t\treturn self.minOperations(nums) + s\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef deductOdd(nums):\n\t\t\tn = len(nums)\n\t\t\tcnt = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcnt += 1\n\t\t\treturn cnt\n\n\t\tdef halfEven(nums):\n\t\t\tn = len(nums)\n\t\t\tallZero = True\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tnums[i] //= 2\n\t\t\t\t\tallZero = False\n\t\t\treturn allZero\n\t\tresult = deductOdd(nums)\n\t\twhile not halfEven(nums):\n\t\t\tresult += 1\n\t\t\tresult += deductOdd(nums)\n\t\treturn result\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tnumzeros = 0\n\t\tn = len(nums)\n\t\tfor i in range(n):\n\t\t\tif nums[i] == 0:\n\t\t\t\tnumzeros += 1\n\t\twhile numzeros < n:\n\t\t\tk = 0\n\t\t\tfor i in range(n):\n\t\t\t\tif nums[i] % 2:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tnumzeros += 1\n\t\t\t\t\telse:\n\t\t\t\t\t\tk = 1\n\t\t\t\t\t\tnums[i] = nums[i] / 2\n\t\t\t\telif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\telse:\n\t\t\t\t\tk = 1\n\t\t\t\t\tnums[i] = nums[i] / 2\n\t\t\tif k == 1:\n\t\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tc = 1\n\t\tcount = 0\n\t\tmaxn = max(nums)\n\t\twhile c * 2 <= maxn:\n\t\t\tc = c * 2\n\t\t\tcount += 1\n\n\t\t@lru_cache\n\t\tdef dfs(n):\n\t\t\tif n <= 1:\n\t\t\t\treturn n\n\t\t\telif n % 2 == 0:\n\t\t\t\treturn dfs(n // 2)\n\t\t\telse:\n\t\t\t\treturn 1 + dfs(n // 2)\n\t\tfor i in nums:\n\t\t\tcount += dfs(i)\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile True:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 1:\n\t\t\t\t\tnums[i] = 0\n\t\t\t\t\tcount += 1\n\t\t\tif max(nums) < 1:\n\t\t\t\tbreak\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] < 2:\n\t\t\t\t\tcontinue\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tcount += 1\n\t\t\t\tnums[i] //= 2\n\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef cod(k, i):\n\t\t\tif k == 0:\n\t\t\t\tself.memo[k] = [self.g[i], self.h[i]]\n\t\t\t\treturn 0\n\t\t\tif k not in self.memo:\n\t\t\t\tif k % 2 == 0:\n\t\t\t\t\tself.g[i] += 1\n\t\t\t\t\tcod(int(k / 2), i)\n\t\t\t\telse:\n\t\t\t\t\tself.h[i] += 1\n\t\t\t\t\tcod(k - 1, i)\n\t\tself.memo = {}\n\t\tl = len(nums)\n\t\tf = [0] * l\n\t\tself.g = [0] * l\n\t\tself.h = [0] * l\n\t\tfor i in range(l):\n\t\t\tf[i] = cod(nums[i], i)\n\t\treturn sum(self.h) + max(self.g)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = 0\n\t\tnew_nums = sorted(nums, reverse=True)\n\t\twhile len(new_nums) > 0:\n\t\t\tif new_nums[-1] == 0:\n\t\t\t\tnew_nums.pop(len(new_nums) - 1)\n\t\t\telif new_nums[-1] == 1:\n\t\t\t\tnew_nums.pop(len(new_nums) - 1)\n\t\t\t\tresult += 1\n\t\t\telse:\n\t\t\t\tflag = True\n\t\t\t\tfor i in range(len(new_nums)):\n\t\t\t\t\tif new_nums[i] & 1 == 1:\n\t\t\t\t\t\tnew_nums[i] -= 1\n\t\t\t\t\t\tresult += 1\n\t\t\t\t\t\tflag = False\n\t\t\t\tif flag:\n\t\t\t\t\tfor i in range(len(new_nums)):\n\t\t\t\t\t\tnew_nums[i] >>= 1\n\t\t\t\t\tresult += 1\n\t\treturn result\n", "def ops(x):\n\tif x == 1:\n\t\treturn (0, 1)\n\tif x % 2 == 0:\n\t\t(d, i) = ops(x // 2)\n\t\treturn (d + 1, i)\n\telse:\n\t\t(d, i) = ops(x - 1)\n\t\treturn (d, i + 1)\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tincrements = 0\n\t\tmax_doubles = 0\n\t\tfor x in nums:\n\t\t\tif x == 0:\n\t\t\t\tcontinue\n\t\t\t(doubs, incrs) = ops(x)\n\t\t\tincrements += incrs\n\t\t\tif doubs > max_doubles:\n\t\t\t\tmax_doubles = doubs\n\t\treturn increments + max_doubles\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = -1\n\t\tl = nums\n\t\twhile 1:\n\t\t\ttf = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif l[i] > 0:\n\t\t\t\t\ttf = 1\n\t\t\t\t\tif l[i] % 2:\n\t\t\t\t\t\tl[i] -= 1\n\t\t\t\t\t\tans += 1\n\t\t\t\t\tif l[i]:\n\t\t\t\t\t\tl[i] //= 2\n\t\t\tif not tf:\n\t\t\t\tbreak\n\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttotal = 0\n\t\tzeros = 0\n\t\tfor i in nums:\n\t\t\tif i == 0:\n\t\t\t\tzeros += 1\n\t\twhile zeros < len(nums):\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tif nums[i] == 0:\n\t\t\t\t\t\tzeros += 1\n\t\t\t\t\ttotal += 1\n\t\t\tallEven = True\n\t\t\twhile allEven and zeros < len(nums):\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] >> 1\n\t\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\t\tallEven = False\n\t\t\t\ttotal += 1\n\t\treturn total\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = sum((num > 0 for num in nums))\n\t\tmax_time = 0\n\t\tfor num in nums:\n\t\t\tadd_op = 0\n\t\t\ttime_op = 0\n\t\t\tY = num\n\t\t\tX = 1\n\t\t\twhile Y > X:\n\t\t\t\tif Y % 2 == 1:\n\t\t\t\t\tY -= 1\n\t\t\t\t\tadd_op += 1\n\t\t\t\telse:\n\t\t\t\t\tY /= 2\n\t\t\t\t\ttime_op += 1\n\t\t\tmax_time = max(max_time, time_op)\n\t\t\tif num > 1:\n\t\t\t\tres += add_op\n\t\tres += max_time\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\teven_num = []\n\t\todd_num = []\n\t\tzero_num = []\n\n\t\tdef category(n, zero_num, even_num, odd_num):\n\t\t\tif n == 0:\n\t\t\t\tzero_num.append(n)\n\t\t\telif n % 2 == 0:\n\t\t\t\teven_num.append(n)\n\t\t\telse:\n\t\t\t\todd_num.append(n)\n\t\tfor n in nums:\n\t\t\tcategory(n, zero_num, even_num, odd_num)\n\t\tans = 0\n\t\twhile len(even_num) or len(odd_num):\n\t\t\tnew_odd_num = []\n\t\t\tif len(odd_num):\n\t\t\t\tans += len(odd_num)\n\t\t\tfor n in odd_num:\n\t\t\t\tn = n - 1\n\t\t\t\tcategory(n, zero_num, even_num, new_odd_num)\n\t\t\todd_num = new_odd_num\n\t\t\tnew_even_num = []\n\t\t\tif len(even_num):\n\t\t\t\tans += 1\n\t\t\tfor n in even_num:\n\t\t\t\tn = n // 2\n\t\t\t\tcategory(n, zero_num, new_even_num, odd_num)\n\t\t\teven_num = new_even_num\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, t: List[int]) -> int:\n\t\tn = len(t)\n\t\tans = 0\n\t\twhile 1:\n\t\t\tz = 0\n\t\t\ti = 0\n\t\t\twhile i < n:\n\t\t\t\tif t[i] % 2:\n\t\t\t\t\tbreak\n\t\t\t\telif t[i] == 0:\n\t\t\t\t\tz += 1\n\t\t\t\ti += 1\n\t\t\tif z == n:\n\t\t\t\treturn ans\n\t\t\tif i == n:\n\t\t\t\tfor j in range(n):\n\t\t\t\t\tt[j] = t[j] // 2\n\t\t\t\tans += 1\n\t\t\tfor j in range(i, n):\n\t\t\t\tif t[j] & 1:\n\t\t\t\t\tt[j] -= 1\n\t\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\twhile any((num != 0 for num in nums)):\n\t\t\todd = 0\n\t\t\tfor (idx, num) in enumerate(nums):\n\t\t\t\tif num & 1:\n\t\t\t\t\tnums[idx] -= 1\n\t\t\t\t\todd += 1\n\t\t\t\t\tans += 1\n\t\t\tif not odd:\n\t\t\t\tfor (idx, num) in enumerate(nums):\n\t\t\t\t\tnums[idx] = num // 2\n\t\t\t\tans += 1\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tvalid = {0: 0}\n\t\tfor i in range(31):\n\t\t\tvalid[2 ** i] = i\n\t\tans = 0\n\t\tmax_multi_step = float('-inf')\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] > 0:\n\t\t\t\tans += 1\n\t\t\telse:\n\t\t\t\tcontinue\n\t\t\t(one_step, multi_step) = (0, 0)\n\t\t\twhile nums[i] not in valid:\n\t\t\t\tif nums[i] & 1:\n\t\t\t\t\tone_step += 1\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\telse:\n\t\t\t\t\tmulti_step += 1\n\t\t\t\t\tnums[i] //= 2\n\t\t\tans += one_step\n\t\t\tmax_multi_step = max(max_multi_step, multi_step + valid[nums[i]])\n\t\tans += max_multi_step\n\t\treturn ans\n", "from math import floor, log\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tfor x in nums:\n\t\t\tfor i in bin(x)[2:]:\n\t\t\t\tif i != '0':\n\t\t\t\t\tans += 1\n\t\tm = max(nums)\n\t\tans += floor(log(m, 2))\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\n\t\tdef it():\n\t\t\tnonlocal ops\n\t\t\tpostAllZero = True\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tn = nums[i]\n\t\t\t\tif n % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tops += 1\n\t\t\t\tif nums[i] > 0:\n\t\t\t\t\tpostAllZero = False\n\t\t\tif postAllZero:\n\t\t\t\treturn\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] /= 2\n\t\t\tops += 1\n\t\t\tit()\n\t\tit()\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnums.sort()\n\t\tresult = 0\n\t\tmultiple = 0\n\t\tlast = 0\n\n\t\tdef find(mx):\n\t\t\tnonlocal last\n\t\t\tif mx <= 1:\n\t\t\t\treturn mx\n\t\t\tif mx % 2 == 1:\n\t\t\t\treturn find(mx - 1) + 1\n\t\t\tlast += 1\n\t\t\treturn find(mx // 2) + 1\n\t\tresult = 0\n\t\tfor (i, n) in enumerate(nums):\n\t\t\tresult += find(n) - last\n\t\t\tmultiple = max(multiple, last)\n\t\t\tlast = 0\n\t\treturn result + multiple\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_mul = 0\n\t\ttotal_add = 0\n\t\tope_dict = {0: (0, 0)}\n\n\t\tdef func(num: int):\n\t\t\tif num in ope_dict:\n\t\t\t\treturn ope_dict[num]\n\t\t\telif num % 2:\n\t\t\t\tr = func(num - 1)\n\t\t\t\tope_dict[num] = (r[0] + 1, r[1])\n\t\t\telse:\n\t\t\t\tr = func(num // 2)\n\t\t\t\tope_dict[num] = (r[0], r[1] + 1)\n\t\t\treturn ope_dict[num]\n\t\tfor n in nums:\n\t\t\t(add, mul) = func(n)\n\t\t\ttotal_add += add\n\t\t\tmax_mul = max(max_mul, mul)\n\t\treturn total_add + max_mul\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnumOperations = 0\n\t\tcompare = [0] * len(nums)\n\t\twhile nums != compare:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tnumOperations += 1\n\t\t\tif nums == compare:\n\t\t\t\treturn numOperations\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tnums[i] /= 2\n\t\t\tnumOperations += 1\n\t\treturn numOperations\n", "class Solution:\n\n\tdef minOperations(self, A: List[int]) -> int:\n\t\tr = 0\n\t\twhile A != [0 for i in A]:\n\t\t\todd = 0\n\t\t\tfor i in range(len(A)):\n\t\t\t\tif A[i] % 2 == 1:\n\t\t\t\t\tA[i] = A[i] - 1\n\t\t\t\t\todd += 1\n\t\t\tif odd == 0:\n\t\t\t\tA = [x // 2 for x in A]\n\t\t\t\tr += 1\n\t\t\telse:\n\t\t\t\tr += odd\n\t\treturn r\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\timport sys\n\t\timport math\n\n\t\tdef h2(n):\n\t\t\tans1 = 0\n\t\t\tans2 = 0\n\t\t\twhile n != 1:\n\t\t\t\tif n % 2 == 0:\n\t\t\t\t\tans1 += 1\n\t\t\t\t\tn /= 2\n\t\t\t\telse:\n\t\t\t\t\tn -= 1\n\t\t\t\t\tans2 += 1\n\t\t\treturn (ans1, ans2)\n\t\tans = 0\n\t\tmixx = -1\n\t\tfor i in nums:\n\t\t\tif i != 0:\n\t\t\t\tans += 1\n\t\t\t\t(ans1, ans2) = h2(i)\n\t\t\t\tans += ans2\n\t\t\t\tmixx = max(ans1, mixx)\n\t\tans += mixx\n\t\treturn int(ans)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\twhile any((num != 0 for num in nums)):\n\t\t\tfor pos in range(len(nums)):\n\t\t\t\tif nums[pos] % 2 != 0:\n\t\t\t\t\tnums[pos] -= 1\n\t\t\t\t\tcount += 1\n\t\t\tif all((num == 0 for num in nums)):\n\t\t\t\treturn count\n\t\t\telse:\n\t\t\t\tnums = [num / 2 for num in nums]\n\t\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcou = [0] * len(nums)\n\t\tcount = 0\n\t\tfor i in range(len(nums)):\n\t\t\twhile nums[i] > 0:\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\t\telse:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\tcou[i] += 1\n\t\tres = max(cou) + count\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcount = 0\n\t\tmax_max_power = 0\n\t\tfor n in nums:\n\t\t\tif n == 0:\n\t\t\t\tcontinue\n\t\t\tmax_power = 0\n\t\t\ttemp = n\n\t\t\twhile temp > 1:\n\t\t\t\tmax_power += 1\n\t\t\t\ttemp >>= 1\n\t\t\tmax_max_power = max(max_max_power, max_power)\n\t\t\twhile max_power >= 0:\n\t\t\t\tif 2 ** max_power <= n:\n\t\t\t\t\tn -= 2 ** max_power\n\t\t\t\t\tcount += 1\n\t\t\t\tmax_power -= 1\n\t\treturn count + max_max_power\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ti = 0\n\t\tk = 0\n\t\tfor x in range(10 ** 9):\n\t\t\tif nums == [0.0] * len(nums):\n\t\t\t\tbreak\n\t\t\tif i >= 1:\n\t\t\t\tk += 1\n\t\t\t\ti = 0\n\t\t\tfor y in range(len(nums)):\n\t\t\t\tif nums[y] % 2 != 0:\n\t\t\t\t\tnums[y] -= 1\n\t\t\t\t\tk += 1\n\t\t\t\tif nums[y] % 2 == 0:\n\t\t\t\t\tnums[y] = nums[y] / 2\n\t\t\t\t\ti += 1\n\t\treturn k\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tarr = [0] * len(nums)\n\t\tcount = 0\n\t\twhile nums != arr:\n\t\t\tf = 0\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tcount += 1\n\t\t\t\t\tf = 1\n\t\t\tif f == 0:\n\t\t\t\tfor i in range(len(nums)):\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\tcount += 1\n\t\treturn count\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\n\t\tdef cal1(arr):\n\t\t\tz = 0\n\t\t\top = 0\n\t\t\tfor i in range(len(arr)):\n\t\t\t\tif arr[i] % 2 == 1:\n\t\t\t\t\tarr[i] -= 1\n\t\t\t\t\top += 1\n\t\t\t\t\tif arr[i] == 0:\n\t\t\t\t\t\tz += 1\n\t\t\treturn (op, z)\n\n\t\tdef cal2(arr):\n\t\t\tflg = 0\n\t\t\tfor i in range(len(arr)):\n\t\t\t\tif arr[i] % 2 == 0 and arr[i] > 0:\n\t\t\t\t\tarr[i] //= 2\n\t\t\t\t\tflg = 1\n\t\t\treturn flg\n\t\tnz = sum([1 for i in nums if i != 0])\n\t\twhile nz > 0:\n\t\t\t(op, z) = cal1(nums)\n\t\t\tans += op\n\t\t\tnz -= z\n\t\t\tans += cal2(nums)\n\t\treturn ans\n", "class Solution:\n\timport math\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef f(s):\n\t\t\tn = 0\n\t\t\tp = 0\n\t\t\twhile s:\n\t\t\t\tif s % 2 == 0:\n\t\t\t\t\ts = s // 2\n\t\t\t\t\tp += 1\n\t\t\t\telse:\n\t\t\t\t\ts -= 1\n\t\t\t\tn += 1\n\t\t\treturn (n, p)\n\t\tnums.sort(key=lambda x: f(x)[1])\n\t\tres = 0\n\t\tinc = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] != 0:\n\t\t\t\t(n, p) = f(nums[i])\n\t\t\t\tres += n - p\n\t\t\t\tres += p - inc\n\t\t\t\tinc = p\n\t\treturn res\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tadd = 0\n\t\tmul = 0\n\t\tfor n in nums:\n\t\t\tm = 0\n\t\t\twhile n > 0:\n\t\t\t\tif n & 1 == 1:\n\t\t\t\t\tadd += 1\n\t\t\t\t\tn -= 1\n\t\t\t\telse:\n\t\t\t\t\tm += 1\n\t\t\t\t\tmul = max(m, mul)\n\t\t\t\t\tn //= 2\n\t\treturn add + mul\n", "class Solution:\n\n\tdef odds(self, nums):\n\t\tops = 0\n\t\tfor i in range(len(nums)):\n\t\t\tif nums[i] % 2 == 1:\n\t\t\t\tnums[i] -= 1\n\t\t\t\tops += 1\n\t\treturn (nums, ops)\n\n\tdef opsc(self, nums, final):\n\t\tif nums == final:\n\t\t\treturn 0\n\t\t(nums, ops) = self.odds(nums)\n\t\tif nums == final:\n\t\t\treturn ops\n\t\tfor i in range(len(nums)):\n\t\t\tnums[i] /= 2\n\t\tops += 1\n\t\tops += self.opsc(nums, final)\n\t\treturn ops\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tfinal = []\n\t\tfor i in range(len(nums)):\n\t\t\tfinal.append(0)\n\t\treturn self.opsc(nums, final)\n", "class Solution:\n\n\tdef soln(self, nums, ans, e, o):\n\t\tif len(nums) == 0:\n\t\t\treturn ans\n\t\tfor i in nums:\n\t\t\tif i % 2 == 0 and i != 0:\n\t\t\t\te.append(i)\n\t\t\telif i != 0:\n\t\t\t\to.append(i)\n\t\tans += len(o)\n\t\tfor i in range(len(o)):\n\t\t\to[i] -= 1\n\t\too = []\n\t\tfor i in range(len(o)):\n\t\t\tif o[i] != 0:\n\t\t\t\too.append(o[i])\n\t\to = oo.copy()\n\t\tfor i in range(len(o)):\n\t\t\to[i] = int(o[i] / 2)\n\t\tif len(e) != 0 or len(o) != 0:\n\t\t\tans += 1\n\t\tfor i in range(len(e)):\n\t\t\te[i] = int(e[i] / 2)\n\t\tnnu = []\n\t\tfor i in e:\n\t\t\tif i != 0:\n\t\t\t\tnnu.append(i)\n\t\tfor i in o:\n\t\t\tif i != 0:\n\t\t\t\tnnu.append(i)\n\t\treturn self.soln(nnu, ans, [], [])\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\te = []\n\t\to = []\n\t\tans = 0\n\t\treturn self.soln(nums, ans, e, o)\n", "from functools import lru_cache\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\n\t\t@lru_cache(None)\n\t\tdef dp(n):\n\t\t\tif n == 0:\n\t\t\t\treturn (0, 0)\n\t\t\telse:\n\t\t\t\t(add, mul) = (0, 0)\n\t\t\t\tif n & 1 == 1:\n\t\t\t\t\t(a, b) = dp(n - 1)\n\t\t\t\t\treturn (a + 1, b)\n\t\t\t\telse:\n\t\t\t\t\t(a, b) = dp(n // 2)\n\t\t\t\t\treturn (a, b + 1)\n\t\tres = 0\n\t\tm = 0\n\t\tfor i in nums:\n\t\t\t(a, b) = dp(i)\n\t\t\tres += a\n\t\t\tm = max(m, b)\n\t\treturn res + m\n", "class Solution:\n\n\tdef modify(self, arr, op, idx):\n\t\tif op == 0:\n\t\t\tarr[idx] = arr[idx] - 1\n\t\tif op == 1:\n\t\t\tfor i in range(len(arr)):\n\t\t\t\tarr[i] = arr[i] / 2\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tresult = [0 for _ in range(len(nums))]\n\t\toperations = 0\n\t\twhile nums != result:\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] % 2 == 1:\n\t\t\t\t\tself.modify(nums, 0, i)\n\t\t\t\t\toperations += 1\n\t\t\tif nums == result:\n\t\t\t\treturn operations\n\t\t\tself.modify(nums, 1, i)\n\t\t\toperations += 1\n\t\treturn operations\n", "import functools\nimport sys\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tsys.setrecursionlimit(10 ** 6)\n\n\t\t@functools.lru_cache(None)\n\t\tdef cal(n):\n\t\t\tif n == 0:\n\t\t\t\treturn (0, 0)\n\t\t\tif n % 2 == 0:\n\t\t\t\t(a, b) = cal(n // 2)\n\t\t\t\treturn (a, b + 1)\n\t\t\telse:\n\t\t\t\t(a, b) = cal(n - 1)\n\t\t\t\treturn (a + 1, b)\n\t\t\treturn (a, b)\n\t\tans = 0\n\t\tmul = 0\n\t\tfor e in nums:\n\t\t\t(a, b) = cal(e)\n\t\t\tans += a\n\t\t\tmul = max(mul, b)\n\t\treturn ans + mul\n", "from typing import List\n\nclass Counter:\n\n\tdef __init__(self):\n\t\tself.c = 0\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef makeAllEven(nums, counter):\n\n\t\t\tdef decrease(num, counter):\n\t\t\t\tif num % 2 != 0:\n\t\t\t\t\tnum -= 1\n\t\t\t\t\tcounter.c += 1\n\t\t\t\treturn num\n\t\t\tret = list(map(lambda n: decrease(n, counter), nums))\n\t\t\treturn ret\n\n\t\tdef allZero(nums):\n\t\t\treturn sum(nums) == 0\n\n\t\tdef makeAllHalf(nums, counter):\n\t\t\tret = list(map(lambda x: x // 2, nums))\n\t\t\tcounter.c += 1\n\t\t\treturn ret\n\t\tcounter = Counter()\n\t\twhile not allZero(nums):\n\t\t\tnums = makeAllEven(nums, counter)\n\t\t\tif not allZero(nums):\n\t\t\t\tnums = makeAllHalf(nums, counter)\n\t\treturn counter.c\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmem = {}\n\t\tans = [[0 for i in range(len(nums))] for j in range(2)]\n\t\tfor (i, num) in enumerate(nums):\n\t\t\ttimes = [0, 0]\n\t\t\t_num = num\n\t\t\twhile _num != 0:\n\t\t\t\tif _num in mem:\n\t\t\t\t\ttimes[0] += mem[_num][0]\n\t\t\t\t\ttimes[1] += mem[_num][1]\n\t\t\t\t\tbreak\n\t\t\t\tif _num % 2 == 1:\n\t\t\t\t\t_num -= 1\n\t\t\t\t\ttimes[0] += 1\n\t\t\t\telse:\n\t\t\t\t\t_num /= 2\n\t\t\t\t\ttimes[1] += 1\n\t\t\tmem[num] = times\n\t\t\tans[0][i] = times[0]\n\t\t\tans[1][i] = times[1]\n\t\tprint(ans)\n\t\treturn sum(ans[0]) + max(ans[1])\n", "from math import log2, log\nfrom typing import List\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\n\t\tdef op0() -> int:\n\t\t\tnonlocal nums\n\t\t\tops = sum([n % 2 for n in nums])\n\t\t\tnums = [n >> 1 << 1 for n in nums]\n\t\t\treturn ops\n\n\t\tdef op1() -> int:\n\t\t\tnonlocal nums\n\t\t\tops = 0\n\t\t\twhile sum([n % 2 for n in nums]) == 0:\n\t\t\t\tops += 1\n\t\t\t\tnums = [n // 2 for n in nums]\n\t\t\treturn ops\n\t\twhile sum(nums):\n\t\t\tops += op0()\n\t\t\tif sum(nums):\n\t\t\t\tops += op1()\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\tchanged = True\n\t\twhile changed:\n\t\t\tchanged = False\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif not x % 2 == 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\tops += 1\n\t\t\t\t\tchanged = True\n\t\t\tdivided = False\n\t\t\tfor (i, x) in enumerate(nums):\n\t\t\t\tif x > 0:\n\t\t\t\t\tnums[i] = nums[i] // 2\n\t\t\t\t\tdivided = True\n\t\t\tif divided:\n\t\t\t\tchanged = True\n\t\t\t\tops += 1\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmemo = {0: (0, 0)}\n\n\t\tdef helper(num):\n\t\t\tif num not in memo:\n\t\t\t\tif num % 2 == 1:\n\t\t\t\t\t(a, b) = helper(num - 1)\n\t\t\t\t\tmemo[num] = (a + 1, b)\n\t\t\t\telse:\n\t\t\t\t\t(a, b) = helper(num // 2)\n\t\t\t\t\tmemo[num] = (a, b + 1)\n\t\t\treturn memo[num]\n\t\ta = b = 0\n\t\tfor num in nums:\n\t\t\t(tmpa, tmpb) = helper(num)\n\t\t\ta += tmpa\n\t\t\tb = max(b, tmpb)\n\t\treturn a + b\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttot_step = 0\n\t\twhile True:\n\t\t\tnot_zero = False\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tnot_zero = True\n\t\t\t\tif nums[i] % 2 != 0:\n\t\t\t\t\tnums[i] -= 1\n\t\t\t\t\ttot_step += 1\n\t\t\tnot_zero = False\n\t\t\tfor i in range(len(nums)):\n\t\t\t\tif nums[i] == 0:\n\t\t\t\t\tcontinue\n\t\t\t\tnot_zero = True\n\t\t\t\tnums[i] = nums[i] / 2\n\t\t\tif not_zero == False:\n\t\t\t\tbreak\n\t\t\ttot_step += 1\n\t\treturn tot_step\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tmax_div = 0\n\t\tmax_sub = 0\n\t\tfor num in nums:\n\t\t\t(div_times, sub_times) = self.calc_steps(num)\n\t\t\tmax_div = max(max_div, div_times)\n\t\t\tmax_sub += sub_times\n\t\treturn max_div + max_sub\n\n\t@lru_cache\n\tdef calc_steps(self, num):\n\t\tif num == 0:\n\t\t\treturn (0, 0)\n\t\tif num == 1:\n\t\t\treturn (0, 1)\n\t\tif num == 2:\n\t\t\treturn (1, 1)\n\t\tif num == 3:\n\t\t\treturn (1, 2)\n\t\t(div_times, sub_times) = self.calc_steps(num // 2)\n\t\treturn (div_times + 1, num % 2 + sub_times)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t_max = -1\n\t\tans = 0\n\t\tfor x in nums:\n\t\t\tans += bin(x).count('1')\n\t\t\t_max = max(_max, x)\n\t\tans += len(bin(_max)) - 3\n\t\treturn ans\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tfor x in nums:\n\t\t\tans += bin(x).count('1')\n\t\twidth = len(bin(max(nums))) - 2\n\t\treturn ans + width - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = max_op = 0\n\t\tfor b in map(bin, nums):\n\t\t\tans += b.count('1')\n\t\t\tmax_op = max(max_op, len(b) - 3)\n\t\treturn ans + max_op\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\top0 = sum((bin(num).count('1') for num in nums))\n\t\top1 = len(bin(max(nums))) - 3\n\t\treturn op0 + op1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\t(sumOp0, maxOp1) = (0, 0)\n\t\tfor num in nums:\n\t\t\t(op0, op1) = (list(bin(num)).count('1'), len(bin(num)[2:]) - 1)\n\t\t\tsumOp0 += op0\n\t\t\tmaxOp1 = max(maxOp1, op1)\n\t\treturn sumOp0 + maxOp1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tmx = 0\n\t\tfor n in nums:\n\t\t\tb = bin(n)\n\t\t\tans += b.count('1')\n\t\t\tmx = max(mx, len(b) - 3)\n\t\treturn ans + mx\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tbns = 0\n\t\tfor x in nums:\n\t\t\tb = bin(x)\n\t\t\tans += b.count('1')\n\t\t\tif x:\n\t\t\t\tbns = max(bns, len(b) - 2)\n\t\treturn ans + max(bns - 1, 0)\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = length = 0\n\t\tfor num in nums:\n\t\t\tbits = bin(num)\n\t\t\tres += bits.count('1')\n\t\t\tlength = max(length, len(bits) - 2)\n\t\treturn res + length - 1\n", "class Solution:\n\n\tdef minOperations(self, arr: List[int]) -> int:\n\t\t(ret, maxx) = (0, 0)\n\t\timport math\n\t\tfor i in arr:\n\t\t\tmaxx = max(maxx, len(bin(i)) - 3)\n\t\t\tret += bin(i).count('1')\n\t\treturn ret + maxx\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tn = len(nums)\n\t\tresult = 0\n\t\tm = 0\n\n\t\tdef bitcount(a):\n\t\t\tcnt = 0\n\t\t\twhile a:\n\t\t\t\tcnt += 1\n\t\t\t\ta &= a - 1\n\t\t\treturn cnt\n\t\tfor num in nums:\n\t\t\tresult += bitcount(num)\n\t\t\tm = max(m, num)\n\t\tfor i in range(32):\n\t\t\tif m > 1:\n\t\t\t\tresult += 1\n\t\t\telse:\n\t\t\t\tbreak\n\t\t\tm >>= 1\n\t\treturn result\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tshifts = 0\n\t\tadds = 0\n\t\tfor n in nums:\n\t\t\tif n == 0:\n\t\t\t\tcontinue\n\t\t\tb = bin(n)[2:]\n\t\t\tshifts = max(shifts, len(b) - 1)\n\t\t\tadds += sum((c == '1' for c in b))\n\t\treturn shifts + adds\n", "import numpy as np\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tops = 0\n\t\tarr = np.array(nums)\n\t\twhile np.sum(arr) != 0:\n\t\t\tinds = np.where(arr % 2 == 1)[0]\n\t\t\tops += len(inds)\n\t\t\tarr[inds] -= 1\n\t\t\tif np.sum(arr) != 0:\n\t\t\t\tarr = arr / 2\n\t\t\t\tops += 1\n\t\treturn ops\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tans = 0\n\t\tshift = 0\n\t\tfor k in nums:\n\t\t\tstrk = bin(k)[2:]\n\t\t\tans += strk.count('1')\n\t\t\tshift = max(shift, len(strk) - 1)\n\t\treturn ans + shift\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tres = 0\n\t\tmul_max = 0\n\t\tfor x in nums:\n\t\t\tif x == 0:\n\t\t\t\tcontinue\n\t\t\tx_bin = bin(x)\n\t\t\tmul = -1\n\t\t\tfor i in x_bin[2:]:\n\t\t\t\tif i == '1':\n\t\t\t\t\tres += 1\n\t\t\t\tmul += 1\n\t\t\tif mul > mul_max:\n\t\t\t\tmul_max = mul\n\t\treturn res + mul_max\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tnum_set_bits = 0\n\t\tmax_bit_len = 0\n\t\tfor n in nums:\n\t\t\tnum_set_bits += bin(n).count('1')\n\t\t\tmax_bit_len = max(max_bit_len, len(bin(n)) - 2)\n\t\treturn num_set_bits + max_bit_len - 1\n", "from math import log2 as l\n\nclass Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt = 0\n\t\tmx = max(nums)\n\t\tif mx & 1 and mx != 1:\n\t\t\tmx -= 1\n\t\tfor x in nums:\n\t\t\twhile x:\n\t\t\t\tif x & 1:\n\t\t\t\t\tcnt += 1\n\t\t\t\tx //= 2\n\t\treturn int(l(mx)) + cnt\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ts = 0\n\t\tb = 0\n\t\tfor n in nums:\n\t\t\tb += (f := f'{n:b}').count('1')\n\t\t\ts = max(s, len(f))\n\t\treturn s - 1 + b\n", "class Solution:\n\n\tdef minOperations(self, nums):\n\t\tresult = 0\n\t\tmax_value = 0\n\t\tfor n in nums:\n\t\t\tmax_value = max(max_value, n)\n\t\t\twhile n:\n\t\t\t\tif n & 1:\n\t\t\t\t\tresult += 1\n\t\t\t\tn = n >> 1\n\t\tif not max_value:\n\t\t\treturn 0\n\t\twhile max_value:\n\t\t\tresult += 1\n\t\t\tmax_value = max_value >> 1\n\t\treturn result - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tones = 0\n\t\tmaxLength = 0\n\t\tfor x in nums:\n\t\t\tx = bin(x)[2:]\n\t\t\tmaxLength = max(maxLength, len(x))\n\t\t\tones += x.count('1')\n\t\tprint((ones, maxLength - 1))\n\t\treturn ones + maxLength - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\thighest_bit = one_bit = 0\n\t\tfor i in range(32):\n\t\t\tfor num in nums:\n\t\t\t\tif num & 1 << i:\n\t\t\t\t\thighest_bit = i\n\t\t\t\t\tone_bit += 1\n\t\treturn highest_bit + one_bit\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tcnt = 0\n\t\tmaxLen = 0\n\t\tfor num in nums:\n\t\t\tnum_bin = bin(num)[2:]\n\t\t\tcnt += sum(map(int, num_bin))\n\t\t\tmaxLen = max(maxLen, len(num_bin))\n\t\treturn cnt + maxLen - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\tto_ret = 0\n\t\tmax_len = 0\n\t\tfor t in nums:\n\t\t\tst = bin(t)[2:]\n\t\t\tmax_len = max(max_len, len(st))\n\t\t\tto_ret += sum(map(int, st))\n\t\treturn to_ret + max_len - 1\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\t\ttwos = len(bin(max(nums))[2:]) - 1\n\t\tones = collections.Counter(''.join((bin(i)[2:] for i in nums)))['1']\n\t\treturn ones + twos\n", "class Solution:\n\n\tdef minOperations(self, nums: List[int]) -> int:\n\n\t\tdef check(num):\n\t\t\tdivisions = inc = 0\n\t\t\twhile num:\n\t\t\t\tif num % 2:\n\t\t\t\t\tinc += 1\n\t\t\t\tdivisions += 1\n\t\t\t\tnum //= 2\n\t\t\treturn (divisions, inc)\n\t\tres = 0\n\t\tm = 1\n\t\tfor n in nums:\n\t\t\t(d, r) = check(n)\n\t\t\tm = max(m, d)\n\t\t\tres += r\n\t\treturn res + m - 1\n"]

starter_code:
class Solution:
    def minOperations(self, nums: List[int]) -> int:

input_output: {"fn_name": "minOperations", "inputs": [[[1, 5]]], "outputs": [5]}

difficulty: MEDIUM

source: leetcode

tags: ['Bit manipulation', 'Data structures', 'Greedy algorithms']

raw_problem:
You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:

You want to use the modify function to convert arr to nums using the minimum number of calls.

Return the minimum number of function calls to make nums from arr.

The test cases are generated so that the answer fits in a 32-bit signed integer.

Example 1:

Input: nums = [1,5]
Output: 5
Explanation: Increment by 1 (second element): [0, 0] to get [0, 1] (1 operation).
Double all the elements: [0, 1] -> [0, 2] -> [0, 4] (2 operations).
Increment by 1 (both elements)  [0, 4] -> [1, 4] -> [1, 5] (2 operations).
Total of operations: 1 + 2 + 2 = 5.

Example 2:

Input: nums = [2,2]
Output: 3
Explanation: Increment by 1 (both elements) [0, 0] -> [0, 1] -> [1, 1] (2 operations).
Double all the elements: [1, 1] -> [2, 2] (1 operation).
Total of operations: 2 + 1 = 3.

Example 3:

Input: nums = [4,2,5]
Output: 6
Explanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums).

Constraints:

1 <= nums.length <= 105

0 <= nums[i] <= 109

question:
You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:
![image](1.png)
You want to use the modify function to convert arr to nums using the minimum number of calls.
Return the minimum number of function calls to make nums from arr.
The test cases are generated so that the answer fits in a 32-bit signed integer.

Example 1:

Input: nums = [1,5]
Output: 5
Explanation: Increment by 1 (second element): [0, 0] to get [0, 1] (1 operation).
Double all the elements: [0, 1] -> [0, 2] -> [0, 4] (2 operations).
Increment by 1 (both elements)  [0, 4] -> [1, 4] -> [1, 5] (2 operations).
Total of operations: 1 + 2 + 2 = 5.

Example 2:

Input: nums = [2,2]
Output: 3
Explanation: Increment by 1 (both elements) [0, 0] -> [0, 1] -> [1, 1] (2 operations).
Double all the elements: [1, 1] -> [2, 2] (1 operation).
Total of operations: 2 + 1 = 3.

Example 3:

Input: nums = [4,2,5]
Output: 6
Explanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums).

Constraints:

- 1 <= nums.length <= 10^{5}
- 0 <= nums[i] <= 10^{9}

data_split: test