Problem:


Score: 300 points

Problem Statement

As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.

Snuke, an employee, would like to play with this sequence.

Specifically, he would like to repeat the following operation as many times as possible:

For every i satisfying 1 \leq i \leq N, perform one of the following: "divide a_i by 2" and "multiply a_i by 3".  
Here, choosing "multiply a_i by 3" for every i is not allowed, and the value of a_i after the operation must be an integer.

At most how many operations can be performed?

Constraints

N is an integer between 1 and 10 \ 000 (inclusive).

a_i is an integer between 1 and 1 \ 000 \ 000 \ 000 (inclusive).

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 a_3 ... a_N

Output

Print the maximum number of operations that Snuke can perform.

Sample Input 1

3
5 2 4

Sample Output 1

3

The sequence is initially {5, 2, 4}. Three operations can be performed as follows:

First, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {15, 6, 2}.

Next, multiply a_1 by 3, divide a_2 by 2 and multiply a_3 by 3. The sequence is now {45, 3, 6}.

Finally, multiply a_1 by 3, multiply a_2 by 3 and divide a_3 by 2. The sequence is now {135, 9, 3}.

Sample Input 2

4
631 577 243 199

Sample Output 2

0

No operation can be performed since all the elements are odd. Thus, the answer is 0.

Sample Input 3

10
2184 2126 1721 1800 1024 2528 3360 1945 1280 1776

Sample Output 3

39



Sample input:
3
5 2 4


Sample output:
3

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if arr == []:
        arr[n] = 1

    return arr

ans = 0
for a in A:
    arr = factorization(a)
    if 2 in arr:
        ans += arr[2]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))

even=[x for x in a if x%2==0]
ans=0
while even!=[]:
    delval=0
    even[0]//=2
    len_even=len(even)
    for i in range(len_even):
        if i==0:
            if even[i]%2!=0:
                del even[i]
                delval+=1
        else:
            if (even[i-delval]*3)%2!=0:
                del even[i-delval]
                delval+=1
            else:
                even[i-delval]*=3
    ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
even=[x for x in a if x%2==0]
ans=0
while even!=[]:
    delval=0
    even[0]//=2
    len_even=len(even)
    for i in range(len_even):
        if i==0:
            if even[i]%2!=0:
                del even[i]
                delval+=1
        else:
            if even[i-delval]%2!=0:
                del even[i-delval]
                delval+=1
    ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=list(map(int,input().split()))
A=1
ANS=0
while A!=0:
  A = 0
  for i in range(N):
    if L[i] % 2 == 0 and A == 0:
      L[i] = L[i] // 2
      A = 1
      break
  if A != 0:
  	ANS += 1
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=list(map(int,input().split()))
A=1
ANS=0
while A!=0:
  A = 0
  for i in range(N):
    if L[i] % 2 == 0 and A == 0:
      L[i] = L[i] // 2
      A = 1
    else:
      L[i] *= 3
  if A != 0:
  	ANS += 1
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, a: "List[int]"):
    # 素因数分解して，2の個数 == ans
    def factorization(n):
        factor = []
        n_ = n
        for i in range(2, int(math.sqrt(n) + 1)):
            if n_ % i == 0:
                cnt = 0
                while n_ % i == 0:
                    n_ = n_ // i
                    cnt += 1
                factor.append([i, cnt])
        if n_ != 1:
            factor.append([n_, 1])
        if n == []:
            factor.append([n, 1])
        return factor

    ans = 0
    for ai in a:
        factor = factorization(ai)
        if factor[0][0] == 2:
            ans += factor[0][1]

    print(ans)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def twonum(n):
    count = Counter(prime_factorize(n))
    return count[2]

n = int(input())
ali = list(map(int, input().split()))
twos = []
for a in ali:
    twos.append(twonum(a))
print(sum(twos))

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
flag_list = [int(i) for i in input().split()]


ans = 0
cont_game = True

while cont_game:
    no_change = 0
    for i in range(num):
        if flag_list[i] % 2 == 0:
            flag_list[i] //= 2
            break
        else:
            no_change += 1
            pass

    if no_change == num:
        break
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
flag_list = [int(i) for i in input().split()]


ans = 0
check_divide = False
cont_game = True

while cont_game:
    for i in range(num):
        if check_divide == False:
            if flag_list[i] % 2 == 0:
                flag_list[i] //= 2
                check_divide = True
            else:
                flag_list[i] *= 3
        else:
            flag_list[i] *= 3

    if check_divide == True:
        check_divide = False
    else:
        break
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
    cnt = 0
    for i in range(1,a + 1):
        if a % 2**i == 0:
            cnt += 1
    else:
        ans += cnt
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] % 2 == 0:
        ans += factorization(A[i])[0][1]
print(ans)

Submission status: Time Limit Exceeded

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

for a in list(map(int,input().split())):
  while not a%2:
    ans+=1
    a//2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

point = 0

for i in li:
    lin = prime_factorize(i)
    point += lin.count(2)

print(point)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
li = list(map(int, input().split()))
a = 0
while any(j % 2 == 0 for j in li):
  for i in range(N):
    if li[i]%2 == 0:
      li[i] = li[i]/2
      a += 1
      break
print(a)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
	input()
	A = list(map(int,input().split()))

	cnt = 0
	EVE = [i for i in A if i % 2 == 0]
	EVE.sort()

	while True:
		if len(EVE) == 0:
			print(cnt)
			break
		else:
			EVE[-1] = EVE[-1] // 2
			if EVE[-1] % 2 == 1:
				EVE.pop(-1)
			else:
				EVE.sort()
			cnt += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))

ods = 0
ans = 0
first = True
while ods != n:
    ods = 0
    div = 0
    for i in range(len(nums)):
        e = nums[i]
        if e % 2 == 0 and div < 1:
            nums[i] = e // 2
            first = False
            div += 1
        else:
            nums[i] *= 3
            ods += 1
    ans += 1
ans -= 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
def f(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n = n//f
        else:f += 2
    if n != 1:
        a.append(n)
    return a

ans = 0
n = int(input())
for i in map(int,input().split()):
    c = collections.Counter(f(i))
    ans += c[2]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = input()
a = list(map(int, input().split()))

c = 0

while True:
    gusu = False

    for i, aa in enumerate(a):
        if gusu is False and a[i] % 2 == 0:
            a[i] /= 2
            gusu = True
            continue

    if gusu is False:
        break

    c += 1

print(c)

Submission status: Time Limit Exceeded

Solution code:
N = input()
a = list(map(int, input().split()))

c = 0

while True:
    gusu = False

    for i, aa in enumerate(a):
        if gusu is False and a[i] % 2 == 0:
            a[i] /= 2
            gusu = True

    if gusu is False:
        break

    c += 1

print(c)

Submission status: Time Limit Exceeded

Solution code:
import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    # c = 0
    tmp = math.sqrt(n) + 1
    tmp = int(tmp)
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor


N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] == 2:
        ans += 1
    buff = trial_division(A[i])
    for el in buff:
        if el == 2:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))

cnt = 0

while True:
    has_divided = False
    for i in range(N):
        if not has_divided and a[i] % 2 == 0:
            a[i] = a[i] // 2
            has_divided = True
        else:
            a[i] *= 3
    if has_divided:
        cnt += 1
    else:
        break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

cnt=0
for a in A:
    f=factorization(a)[0]
    if f[0]==2:
        cnt+=f[1]

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def div2(n):
  i=n
  a=0
  while True:
    if i%2!=0:
      return a
    i%=2
    a+=1

n=int(input())
a=list(map(int,input().split()))
ans=0
for i in a:
  ans+=div2(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
def q77(N, a):
    i = 0
    while True:
        b = False
        for j in range(N):
            a[j] = a[j]/2
            if a[j].is_integer():
                i += 1
                b = True
                break
        if not b:
            break
    return i

N = int(input())
a = [int(i) for i in input().split()]

print(q77(N, a))

Submission status: Time Limit Exceeded

Solution code:
import math
def q77(N, a):
    i = 0
    while True:
        b = False
        for j in range(N):
            l = a[j]/2
            if l.is_integer():
                a[j] = l
                i += 1
                b = True
                break
        if not b:
            break
    return i

N = int(input())
a = [int(i) for i in input().split()]

print(q77(N, a))

Submission status: Time Limit Exceeded

Solution code:
import math
def q77(N, a):
    i = 0
    while True:
        b = False
        for j in range(N):
            if (a[j]/2).is_integer():
                a[j] = a[j]/2
                i += 1
                b = True
                break
        if not b:
            break
    return i

N = int(input())
a = [int(i) for i in input().split()]

print(q77(N, a))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))

ans=0
for _ in range(2*(10**4)):
    count=0
    for i in range(n):
        if a[i]%2!=0:
            a[i]*=3
            count+=1
        else:
            a[i]=a[i]//2
            break
    if count==n:
        break
    if count!=n:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))

ans=0
for _ in range(10**5):
    count=0
    for i in range(n):
        if a[i]%2!=0:
            a[i]*=3
            count+=1
        else:
            a[i]=a[i]//2
            break
    if count==n:
        break
    if count!=n:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
while True:
    flag = False
    for i in range(N):
        if not flag and A[i] % 2 == 0:
            A[i] = A[i] // 2
            flag = True
        else:
            A[i] *= 3
    if flag:
        ans += 1
    else:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
"""
一番大きい偶数を2で割る
それ以外は3倍
を繰り返す
奇数だけになったら終了
"""
# O(n)
def f(L):
    even = []
    for l in L:
        if l%2 == 0:
            even.append(l)

    if even == []:
        return -1
    else:
        return max(even)

maxEven = f(a)
while True:
    if maxEven == -1:
        print(ans)
        exit()
    else:
        for i in range(n):
            if a[i] == maxEven:
                a[i] = a[i] // 2
            else:
                a[i] *= 3
            if a[i]%2 == 0:
                maxEven = max(maxEven, a[i])
        ans += 1

Submission status: Time Limit Exceeded

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in a:
    li = factorization(i)
    for j in li:
        if j[0] == 2:
            ans += j[1]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))
even_a = [i for i in a if i%2==0]
even_a.sort()
num = len(even_a)
count = 0

if num == 0:
    print(0)
    exit()

i = 0
while even_a[i] % 2 == 0:
    even_a[i] //= 2
    count += 1
    for j in range(i+1, num):
        even_a[j] *= 3
    if even_a[i] % 2 != 0:
        i += 1
    if i == num:
        break

print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    A = string_to_int(inputs[0])
    odd_count = 0
    count = -1
    while odd_count < len(A):
        odd_count = 0
        first_even_i = -1
        count += 1
        for i in range(len(A)):
            if A[i] % 2 == 0:
                if first_even_i == -1:
                    first_even_i = i
            elif A[i] % 2 == 1:
                odd_count += 1
        if first_even_i != -1:
            A[first_even_i] /= 2
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
A=list(map(int,input().split()))
count=0
flag=False
while any(a%2==0 for a in A):
  count+=1
  flag=False
  for i in range(n):
    if A[i]%2==0 and flag==False:
      A[i]//=2
      flag=True
    else:
      A[i]*=3
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    A = string_to_int(inputs[0])
    odd_num = 0
    count = -1
    while odd_num < len(A):
        odd_num = 0
        devided = False
        for i, _ in enumerate(A):
            if A[i] % 2 == 0:
                if not devided:
                    A[i] /= 2
                    devided = True
            else:
                odd_num += 1
        count += 1
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
  ans *= a[i]
cnt = 0
while True:
  if ans % 2 == 0:
    ans //= 2
    cnt += 1
  else:
    print(cnt)
    break

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
li = [int(x) for x in input().split()]
ans = 0
isAvailable = False
for a in li:
    if a % 2 == 0:
        isAvailable = True
        for _ in range(a):
            if a % 2 == 0:
                a /= 2
                ans += 1
if isAvailable:
    print(ans)
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
def factorize2(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    >>> factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


N = int(input())
A = list(map(int, input().split()))

cnt = 0
for a in A:
    res = factorize2(a)
    if len(res) > 0:
        fct, num = res[0]
        if fct == 2:
            cnt += num
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def prime_decomposition(n):
  i = 2
  table = []
  counter = 0
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i == 2:
          counter += 1
      table.append(i)
    i += 1
  if n > 1:
    if n == 2:
        counter += 1
    table.append(n)
  return counter


N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] % 2 == 0:
        ans += prime_decomposition(A[i])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

sum_div = 0
for i in range(N):
  temp_div = A[i]
  while True:
    if temp_div%2 == 0:
      sum_div += 1
      temp_div = A[i]//2
    else:
      break
print(sum_div)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(i) for i in input().split()]

b = 0
c = 0
cnt = 0
flag = False
while True:
    b = 0
    c = 0
    for i in range(n):
        if a[i] % 2 == 0 and c == 0:
            a[i] /= 2
            c += 1
        else:
            b += 1
    #print(a,b)
    if b != n:
        cnt += 1
    else:
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import os, sys, re, math

n = int(input())
a = list(map(int,input().split(' ')))


cnt = 0
while True:
    a.sort(reverse=True)
    if (sum(map(lambda x: x % 2, a))) == n:
        break
    flg = False
    for i in range(n):
        if a[i] % 2 == 0 and flg == False:
            a[i] = a[i] // 2
            flg = True
        else:
            a[i] = a[i] * 3
    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = [int(s) for s in input().split()]
i = 0
flag = 0
count = 0
while i < len(A):
  
  
  if A[i] %2 == 0:
    flag = 0
    A[i] = A[i] /2
    count += 1
    i = 0
    
    continue
  else:
    flag += 1
    if flag == len(A):
      print(count)
      exit()
    i += 1

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
N = int(input())
L = list(map(int, input().split()))

cnt = 0
tri_cnt = 0
mem = 0

#全てが奇数になるまで実行し続ける
while(tri_cnt != len(L)):
    if(L[mem]%2 != 0):
        mem += 1
    else:
        L[mem] //= 2
        # for i in range(len(L)):
        #     if(i != mem):
        #         #L[i] = L[i] * 3
        #         print('',end='')
        cnt += 1

    tri_cnt = 0
    for i in range(len(L)):
        if (L[i] % 2 != 0):
            tri_cnt += 1
    # print(L)
    # print(tri_cnt)
else:
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
N = int(input())
L = list(map(int, input().split()))

cnt = 0
tri_cnt = 0
mem = 0

#全てが奇数になるまで実行し続ける
while(tri_cnt != len(L)):
    if(L[mem]%2 != 0):
        mem += 1
    else:
        L[mem] //= 2
        for i in range(len(L)):
            if(i != mem):
                #L[i] = L[i] * 3
                print('',end='')
        cnt += 1

    tri_cnt = 0
    for i in range(len(L)):
        if (L[i] % 2 != 0):
            tri_cnt += 1
    # print(L)
    # print(tri_cnt)
else:
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
N = int(input())
L = list(map(int, input().split()))

cnt = 0
tri_cnt = 0
mem = 0

#全てが奇数になるまで実行し続ける
while(tri_cnt != len(L)):
    if(L[mem]%2 != 0):
        mem += 1
    else:
        L[mem] //= 2
        for i in range(len(L)):
            if(i != mem):
                L[i] *= 3
        cnt += 1

    tri_cnt = 0
    for i in range(len(L)):
        if (L[i] % 2 != 0):
            tri_cnt += 1
    # print(L)
    # print(tri_cnt)
else:
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int,input().split()))

cnt = 0
s = 0

while True:
    for i in range(n):
        if s == 0:
            if li[i] % 2 == 0:
                li[i] //= 2
                s = 1
            else:
                li[i] *= 3
        else:
            li[i] *= 3
    else:
        if s == 0:
            break
        s = 0
        cnt += 1
        
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
c = input()

m = map(int, raw_input().split())
h = []
conte = 0
while(True):
	entrou = False
	
	
	
	for i in range(len(m)-1,-1,-1):
		if (not entrou and m[i]%2==0):
			entrou = True;
			conte += 1
			m[i] /= 2
		if(m[i]%2==0):
			m[i] *= 3
		
		else:
			m.pop(i)
	
	if(not entrou):
		print conte
		break

Submission status: Time Limit Exceeded

Solution code:
n = int(raw_input())
m = [int(x) for x in raw_input().split()]
a = 0
possible = True
while possible:
    dividiu = False
    for i in range(n):
        if not dividiu and m[i] % 2 == 0:
            m[i] /= 2
            dividiu = True
        else:
            m[i] *= 3
    if not dividiu:
        possible = False
    else:
        a += 1

print a

Submission status: Time Limit Exceeded

Solution code:
c = input()

m = map(int, raw_input().split())
conte = 0
while(True):
	entrou = False
	
	for i in range(c):
		if (not entrou and m[i]%2==0):
			entrou = True;
			conte += 1
			m[i] /= 2
		else:
			m[i] *= 3
	
	if(not entrou):
		print conte
		break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
aa = [int(a[i]) for i in range(n)]
b = 1
for i in range(n):
  s = list(str(aa[i]))
  ss = int(s[-1])
  if ss == 0 or ss == 2 or ss == 4 or ss == 6 or ss == 8:
  	b = b * aa[i]

c = 0
cnt = 0
while c < 1:
  if b % 2 == 0:
    b = b // 2
    cnt = cnt + 1
  else:
    c = 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
aa = [int(a[i]) for i in range(n)]
b = 1
for i in range(n):
  b = b * aa[i]
c = 0
cnt = 0
while c < 1:
  if b % 2 == 0:
    b = b // 2
    cnt = cnt + 1
  else:
    c = 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
input()
a = list(map(int,input().split(" ")))

c=0
flag=True
while(flag):
    for i in range(len(a)):
        flag=False
        if a[i]%2==0:
            a[i]//=2
            c+=1
            flag = True
            break
            
print(c)

Submission status: Time Limit Exceeded

Solution code:
from copy import deepcopy

n = int(input())
a = list(map(int,input().split()))

counter = 0
while(True):
    b = deepcopy(a)
    undivided = True
    for i,v in enumerate(b):
        if v%2 is 0 and undivided:
            a[i] = v//2
            undivided = False
        else:
            a[i] = v*3
    if undivided:
        break
    else:
        counter += 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n = int(input())
num = reduce(lambda x,y: x*y, list(map(int, input().split())))
count = 0

while num%2 == 0:
    num = num//2
    count += 1
    
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
A = [int(i) for i in input().split()]

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor

ans = 0
for i in A:
    ans += trial_division(i).count(2)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
count = 0
def prime_decomposition(n):
    i = 2
    table = []
    global count
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
            if i == 2:
                count += 1
        i += 1
    if n > 1:
        table.append(i)
        if i == 2:
            count += 1
    return table
readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
p = readl()

for i in p:
    prime_decomposition(i)
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))

cnt = 0
flg = True
while flg:
  flg = False
  for i in range(0, n):
    if not a[i]%2:
      a[i] = a[i] / 2
      flg = True
      cnt += 1
      break

print(cnt)

Submission status: Time Limit Exceeded

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

N = int(input())
L = [int(v) for v in input().split()]

f = True
c = 0
while f:
    f = False
    
    for i in range(N):
        if f == False and L[i] % 2 == 0:
            c += 1
            L[i] = L[i] // 2
            f = True
            break
            
print(c)

Submission status: Time Limit Exceeded

Solution code:
N, *a = map(int, open(0).read().split())
ans = 0
flag = True
while flag:
    cnt = 0
    for i in range(N):
        if a[i] % 2 != 0:
            continue
        elif a[i] % 2 == 0 and cnt == 0:
            a[i] //= 2
            cnt += 1
            break

    if cnt == 0:
        flag = False
    else:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, *a = map(int, open(0).read().split())
ans = 0
flag = True
while flag:
    cnt = 0
    for i in range(N):
        if a[i] % 2 == 0 and cnt == 0:
            a[i] //= 2
            cnt += 1
        else:
            a[i] *= 3
    else:
        if cnt == 0:
            flag = False
        else:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
input()

a = list(map(int, input().split()))

count = 0
flag = True
while flag:
    flag = False
    for i, aa in enumerate(a):
        if aa % 2 == 0:
            a[i] = int(a[i] / 2)
            flag = True
            break
    if flag:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
K = 0
for i in range(N):
  while True:
    if(A[i]%2==0):
      A[i]==A[i]//2
      K+=1
    else:
      break
print(K)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

import math
import collections


def trial_division_sqrt(n):
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def solve(N: int, a: "List[int]"):
    print(sum([trial_division_sqrt(v)[2] for v in a]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

N = INT()
a = LIST()
count = 0
flag = 0

while flag == 0:
	# print(a)
	for i in range(N):
		if a[i] % 2 == 0:
			a[i] = int(a[i]/2)
			count += 1
			break
	else:
		flag = 1
print(count)

Submission status: Time Limit Exceeded

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

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

N = INT()
a = LIST()
count = 0
flag = 0
while flag == 0:	
	for i in range(N):
		if a[i] % (1024**3) == 0:
			a[i] /= (1024**3)
			count += 30
			break
	else:
		flag = 1
flag = 0
while flag == 0:
	for i in range(N):
		if a[i] % 2 == 0:
			a[i] /= 2
			count += 1
			break
	else:
		flag = 1
print(count)