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()))
t = 0

while True:
    a.sort(reverse = True)
    x = True
    for i in range(n):
        if a[i] % 2 == 0:
            if x:
                a[i] = a[i] // 2
                x = False
    if x:
        print(t)
        exit(0)
    else:
        t += 1

Submission status: Time Limit Exceeded

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

while True:
    a.sort(reverse = True)
    x = True
    for i in range(n):
        if a[i] % 2 == 0:
            if x:
                a[i] = a[i] // 2
                x = False
            else:
                a[i] *= 3
        else:
            a[i] * 3
    if x:
        print(t)
        exit(0)
    else:
        t += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
flg = True
t = 0

while flg:
    p = -1
    for i in range(n):
        if a[i] % 2 == 0:
            if p == -1:
                p = i
            else:
                if a[p] < a[i]:
                    p = i

    for i in range(n):
        if i != p:
            a[i] *= 3
        else:
            a[i] = a[i] // 2
    
    if p == -1:
        flg = False
    else:
        t += 1

print(t)

Submission status: Time Limit Exceeded

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

ans = 0
t = 1
while t != 0:
  t = 0
  for i in range(n-1, -1 ,-1):
    if t == 0 and a[i]%2 == 0 and a[i] != 2:
      a[i] //= 2
      t += 1
      ans += 1
    else: a[i] *= 3
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans, cnt = 0, 0
b = True

while b:
    cnt = 0
    for i in range(len(a)):
        if cnt == 0:
            if a[i] % 2 == 0:
                a[i] = a[i] // 2
                cnt = 1
            else:
                a[i] = a[i] * 3
        else:
            a[i] = a[i] * 3
    if cnt == 1:
        ans += 1
    else:
        b = False
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
while True:
  if all(i%2==1 for i in a): break
  ans += 1
  t = 0
  for i in range(n):
    if a[i]%2 == 1: a[i] *= 3
    else:
      if t == 0 and a[i] != 2:
        a[i] //= 2
        t += 1
      else: a[i] *= 3

print(ans)

Submission status: Time Limit Exceeded

Solution code:
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


def main():
    n = int(input())
    As = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        if factorization(As[i])[0][0] == 2:
            ans += factorization(As[i])[0][1]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

count = 0
while any([i % 2 == 0 for i in nums]):
    count += 1
    div_index = max([(i, v) for i, v in enumerate(nums) if v % 2 == 0],
                    key=lambda x: x[1])[0]
    for i in range(len(nums)):
        if i == div_index:
            nums[i] //= 2
        else:
            nums[i] *= 3

print(count)

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 Counter(a)

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

ans = 0

for i in a:
    ans += prime_factorize(i)[2]
print(ans)

Submission status: Time Limit Exceeded

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

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

def isallodd(arr):
    haseven = False
    for i in arr:
        if i%2==0:
            haseven = True
            break
    if haseven:
        return False
    else:
        return True

ans = 0 
while isallodd(a)==False:
    on = False
    for i in range(len(a)):
        if a[i]%2==1:
            a[i]*=3
        else:
            if on == False:
                a[i]//=2
                on = True
            else:
                a[i]*=3
    ans += 1 

print(ans)

Submission status: Time Limit Exceeded

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

# check
cnt = 0
evens = [a for a in A if a % 2 == 0]
while len(evens) > 0:
    max_even = max(evens)
    max_even_idx = A.index(max_even)

    A = [a * 3 if ind != max_even_idx else a // 2 for ind, a in enumerate(A)]

    cnt += 1
    evens = [a for a in A if a % 2 == 0]

print(cnt)

Submission status: Time Limit Exceeded

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

# check
cnt = 0
evens = [a for a in A if a % 2 == 0]
while len(evens) > 0:
    max_even = max(evens)
    max_even_idx = A.index(max_even)
    A[max_even_idx] //= 2

    fl = False
    for idx, a in enumerate(A):
        if fl is False and idx == max_even_idx:
            fl = True
            continue
        a *= 3

    cnt += 1
    evens = [a for a in A if a % 2 == 0]

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 素因数分解
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, *a = map(int, read().split())

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

Submission status: Time Limit Exceeded

Solution code:
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):
    t=factorization(a[i])
    if t[0][0]==2:
        ans+=t[0][1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
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):
    t=factorization(a[i])
    for j,k in t:
        if j==2:
            ans+=k
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=list(map(int,input().split()))
cnt=0
for i in range(n):
  c=0
  while l[i]!=1:
    if l[i]%2==0:
      l[i]=l[i]//2
      c+=1
  cnt+=c
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int,input().split()))
a = 1
count = 0
for i in range(n):
    a = a*li[i]
while a % 2 == 0:
    a = a // 2
    count += 1
print(count)

Submission status: Time Limit Exceeded

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

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


ans = 0
for i in range(N):
    ans += prime_factor(A[i]).count(2)

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()
a = inlist()
c = 0
while True:
    done1 = 0
    for i in range(N):
        if a[i] % 2 == 0 and done1 == 0:
            a[i] = a[i] // 2
            done1 = 1
            c += 1
        else:
            a[i] *= 3
    if done1 == 0:
        break

print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy
n = input()
a =[int(e) for e in input().split(" ")]

a_n = numpy.array(a)
count = 0

for kk in range(10000):
    TF = a_n%2==0
    if any(TF):
        tmp = 0
        tmp_i = 0
        for i,j in enumerate(TF):       
            if j:
                if tmp <= a_n[i]:
                    tmp = a_n[i]
                    tmp_i = i
        a_n = a_n * 3
        a_n[tmp_i] = a_n[tmp_i]/6
        count += 1
    else:
        break
print(count)

Submission status: Time Limit Exceeded

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

while any(a[i]%2==0 for i in range(n)):
    m=0
    for j in range(n):
        if a[j]%2==0:
            if a[j]>m:
                m=a[j]
                index=j

    for k in range(n):
        a[k]*=3
    
    a[index]=a[index]//6
    cnt+=1

print(cnt)

Submission status: Time Limit Exceeded

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

def main():
    *N, = map(int, open(0).read().split())
    A = N[1:]
    N = N[0]

    cnt = 0
    for i in A:
        if i % 2 == 0:
            for j in range(0, max(A)):
                i = i//2
                cnt = cnt + 1
                if (i < 2) or not (i % 2 == 0):
                    break
    print(cnt)


main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lis = list(map(int,input().split()))
S = lis[0]
for i in range(2,N+1):
    S *= lis[i-1]
cnt = 0
while S % 2 == 0:
    S = S//2
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
for ai in A:
    if ai % 2 == 0:
        while ai != 1:
            ai /= 2
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
m = 1
for i in a:
    m *= i

while True:
    if m % 2 == 0:
        ans += 1
        m //= 2
    else:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**9)
from functools import reduce
from operator import mul

def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

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

ans1=0
#ans2=0
p=reduce(mul,A)
ans1=two(p,ans1)
#for i in range(N):
#    ans2=two(A[i],ans2)
print(ans1)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**9)
from functools import reduce
from operator import mul


def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

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

ans1=0
#ans2=0
p=reduce(mul,A)
ans1=two(p,ans1)
#for i in range(N):
#    ans2=two(A[i],ans2)
print(ans1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))
cnt = 1
for i in range(N):
    cnt *= a[i]
an = 0
while cnt%2 == 0:
    cnt //= 2
    an += 1
print(an)

Submission status: Time Limit Exceeded

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

for j in range(n):
  if a[j]%2 == 0:
    arr = []
    temp = a[j]
    for i in range(2, int(-(-a[j]**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([a[j], 1])
        
    count = count + arr[0][1]
    
print(count)

Submission status: Time Limit Exceeded

Solution code:
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()))
count = 0

for i in range(n):
  if a[i]%2 == 0:
    temp = factorization(a[i])
    count = count + temp[0][1]
    
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
lst = [2184, 2126, 1721, 1800, 1024, 2528, 3360, 1945, 1280, 1776]
n = input()
lst = [int(e) for e in input().split()]
count = 0
f = True
while(f):
    f = False
    for i in range(len(lst)):
        if(lst[i]%2 == 0):
            m = i
            f = True
            break

    if(f):
        count += 1
    else:
        break

    for i in range(len(lst)):
        if (lst[i]%2 == 0)and(lst[i] > lst[m]):
            m = i

    for i in range(len(lst)):
        if (i == m):
            lst[i] = int(lst[i]/2)
        else:
            lst[i] *= 3 
print(count)

Submission status: Time Limit Exceeded

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

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

fac = [0] * N
for i in range(N):
    if a[i]%2==0:
        arr = factorization(a[i])
        fac[i] = arr[0][1]

print(sum(fac))

Submission status: Time Limit Exceeded

Solution code:
# 素因数分解
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table
  
N = int(input())
a = list(map(int,input().split()))

ans = 0

for i in range(N):
    ans += prime_decomposition(a[i]).count(2)
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def triple_or_half(arr):
  sw = 0 
  for num, i in enumerate(arr):
    if i%2 + sw:
      arr[num] *= 3
    else:
      sw = 1
      arr[num] = arr[num] // 2
  if sw:
    return arr
  else:
    return []
  
input()
a = list(map(int,input().split()))
cnt = 0

while a:
  a = triple_or_half(a)
  if a:
    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
flug=1

while 1:
    flug=0
    for i in range(n):
        if a[i]%2==0 and flug==0:
            a[i]=a[i]//2
            flug=1
        else:
            a[i]=a[i]*3
    else:
        if flug==1:
            ans+=1
        else:
            print(ans)
            exit()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- 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


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

    result = 0

    for a in A:
        fact = factorization(a)[0]
        if fact[0] == 2:
            result += fact[1]
    print(result)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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


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

    result = 0

    for a in A:
        result += prime_decomposition(a).count(2)
    print(result)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


num_list = []

cnt = 0

while True:
    even_count = 0
    #print(A)

    if not "even" in list(map(lambda x: "even" if x % 2 == 0 else "odd", A)):
        break

    for index, num in enumerate(A):
        if not even_count == 1 and num % 2 == 0:
            num = num//2
            even_count += 1
            A[index] = num

        else:
            num = num * 3
            A[index] = num

    cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=0
b=a[0]
for i in range(1,n):
    b=b*a[i]

for i in range(100000):
    if b%2==0:
        b=b//2
        c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
j = 0
if L == []:
  print(0)
  sys.exit(0)
even = numpy.prod(L)
while (even % 2**j == 0):
  j += 1
print(j-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
even = 1
j = 0
if L == []:
  print(0)
  sys.exit(0)
for i in range(len(L)):
  even *= L[i]
while (even % 2**j == 0):
  j += 1
print(j-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
L = [i for i in map(int,input().split()) if i%2 == 0]
even = 1
res = 0
if L == []:
  print(0)
  sys.exit(0)
else:
  for i in range(len(L)):
    even *= L[i]
  while even != 0 and even % 2 == 0:
    even //= 2 
    res += 1
print(res)

Submission status: Time Limit Exceeded

Solution code:
N = input()
a = input().split()
import numpy as np
a = np.array(a).astype(int).tolist()
s = []
count = 0
al = False
while(1):
    s = []
    al = False
    for aa in a:
        if aa % 2 == 0:
            s.append(True)
        else:
            s.append(False)
    #print(s)
    if np.count_nonzero(s) == 0:
        break
    count = count + 1
    for i,ss in enumerate(s):
        if ss and not al:
            a[i] = a[i] / 2
            al = True
        elif not ss or al:
            a[i] = a[i];
    
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

def mul3(n):
    return n*3

count = 0
while any([a[i] % 2 == 0 for i in range(n)]):
    a = list(map(mul3, a))
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] //= 6
            break
    count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
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


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        tmp = factorization(a[i])
        if tmp[0][0] == 2:
            ans += tmp[0][1]

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
f=True
while f:
    b=0
    for i in range(n):
        if a[i]%2==0:
            count+=1
            a[i]/=2
            for j in range(n):
                if a[j]%2==0:
                    b+=1

            if b==0:
                print(count)
                exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

N = int(input().strip())
a_list = list(map(int, input().rstrip().split()))
#-----

a_list.sort(reverse=True)

Flag=True
cnt=0
while Flag:

    even_flag=False
    for i in range(len(a_list)):
    
        if a_list[i] % 2 == 1:
            #a_list[i] *= 3
            pass
        elif even_flag == False and a_list[i] != 0:
                a_list[i] /= 2
                even_flag = True
        
    if even_flag == True:
        cnt += 1
    else:
        Flag=False
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
ans = 0

while sum(np.mod(a,2)) != len(a):
    a = a * 3
    for i in range(len(a)):
        if a[i] % 2 == 0:
            a[i] = a[i] / 2
            break
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
p=np.prod(a)
c=0
while p%2==0:
  p//=2
  c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
a = list(map(int, 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


count = 0
for i in a:
    temp = trial_division(i)
    count += temp.count(2)

print(count)

Submission status: Time Limit Exceeded

Solution code:
import collections
import numpy as np

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

N =int(input())

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

ans_array = np.zeros(N)

for i in range(N):
    dummy = prime_factorize(a[i])
    if collections.Counter(dummy).get(2) is not None:
        ans_array[i] = collections.Counter(dummy)[2]
ans = int(sum(ans_array))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))
answer = 0
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

for ai in a:
    # print(prime_decomposition(ai))
    # # if 2 in prime_decomposition:
    # #     print('Yes')
    # print(prime_decomposition(ai).count(2))
    answer += prime_decomposition(ai).count(2)

print(answer)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort()
i = N - 1
c = 0
while i >= 0:
    i = N -1
    while a[i] % 2 != 0:
        i -= 1
        if i < 0:
            print(c)
            exit()
    max_ = a[i] // 2
    a = list(map(lambda x: x * 3, a))
    a[i] = max_
    c += 1
    a.sort()

Submission status: Time Limit Exceeded

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

cnt = 0
while all([i%2!=0 for i in a])!=True:
    for i in range(n):
        if a[i]%2==0:
            a[i]//=2
            cnt+=1
            break
print(cnt)

Submission status: Time Limit Exceeded

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

while True:
  for i in range(N):
    if a[i]%2==0:
      a[i]=a[i]//2
      ans+=1
      break
  else:
    break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import lru_cache
import sys
import numpy as np

sys.setrecursionlimit(10**8)

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

@lru_cache(maxsize=None)
def dp(*x):
    xnum = np.array(x)
    x_seki = xnum.prod()
    result = 0
    while x_seki % 1 == 0:
        x_seki /= 2
        result += 1
    return result - 1
print(dp(*X))

Submission status: Time Limit Exceeded

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

ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in l:
  while i % 2 == 0:
    count += 1
    i // 2
print(count)

Submission status: Time Limit Exceeded

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

ans = 0
while (1):
   b = [x % 2 for x in a]
   if (0 not in b):
      break

   c = b.index(0)
   a = [int(a[i]/2) if i == c else a[i] for i in range(n)]
   ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def is_even(n):
    return n & 1 == 0

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


count = 0
while True:
    maxidx = 0
    maxval = 0
    even_flag = False
    for i, v in enumerate(a):
        if is_even(v):
            even_flag = True
            if maxval < v:
                maxval = v
                maxidx = i
        a[i] *= 3

    if not even_flag:
        break

    a[maxidx] = int(a[maxidx] / 6)
    count += 1

print(count)

Submission status: Time Limit Exceeded

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

seki = 1

for a_i in A:
        seki *= a_i

count = 0

while seki % 2 == 0:
        seki = seki // 2
        count += 1
'''

count = 0

for a_i in A:
        while a_i % 2 == 0:
                a_i = a_i // 2
                count += 1
'''

print(count)

Submission status: Time Limit Exceeded

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

seki = 1

for a_i in A:
        seki *= a_i

count = 0

while seki % 2 == 0:
        seki = seki // 2
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]%2==0:
    while a[i]%2==0:
      cnt+=1
      a[i]//2
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[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)