input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
# 素因数分解
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(eval(input()))
a = list(map(int,input().split()))
ans = 0
for ... | N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in range(N):
num = a[i]
while num % 2 == 0:
num = num // 2
ans += 1
print(ans) | p03325 |
import math
n = int(eval(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:
... | import math
n = int(eval(input()))
a = list(map(int, input().split()))
def trial_division(n):
factor = []
tmp = int(math.sqrt(n)) + 1
for _ in range(2,tmp):
while n % 2 == 0:
n //= 2
factor.append(2)
if not factor:
return [n]
else:
fac... | p03325 |
n = int(eval(input()))
a = list(map(int, input().split()))
def trial_division(n):
#2で割った因数を格納するリスト
factor = []
#2で割れなくなった時点でストップ
while n % 2 == 0:
n //= 2 # 2で割った商を切り捨てて代入
factor.append(2)
#nが一度も2で割れなかったらそのまま返す
if not factor:
return [n]
else:
... | n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for i in a:
while i % 2 == 0:
i = i // 2
cnt += 1
print(cnt)
| p03325 |
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(n):
for j in range(29, 0, -1):
if a[i] % (2 ** j) == 0:
ans += j
break
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
def count_2(x):
if x % 2 != 0:
return 0
else:
return count_2(x // 2) + 1
ans = 0
for i in range(n):
ans += count_2(a[i])
print(ans)
| p03325 |
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(eval(input()))
A=list(map(int,input().split()))
ans1=0
#ans2=0
p=reduce(mul,A)
ans1=two(p,ans1)
#for i in ra... | #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(eval(input()))
A=list(map(int,input().split()))
#ans1=0
#ans2=0
#p=reduce(mul,A)
p2=1
for a in A:
... | p03325 |
def counter(value):
count = 0
while value % 2 == 0:
count += 1
value /= 2
return count
n = int(eval(input()))
a = list(map(int, input().split()))
count = 0
for i in range(n):
if a[i] % 2 == 0:
count += counter(a[i])
print(count)
| ans = 0
N = int(eval(input()))
a = list(map(int, input().split()))
for n in a:
while not n % 2:
ans += 1
n //= 2
print(ans) | p03325 |
ans = 0
N = int(eval(input()))
a = list(map(int, input().split()))
for n in a:
while not n % 2:
ans += 1
n //= 2
print(ans) | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
ans = 0
for a in list(map(int, input().split())):
while not a % 2:
ans += 1
a //= 2
print(ans)
if __name__ == '__main__':
main()
| p03325 |
# encoding: utf-8
N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for ai in a:
ai_tmp = ai
ans_tmp = 0
for i in range(32):
if ai_tmp % 2: break
else:
ans_tmp += 1
ai_tmp = ai_tmp // 2
ans += ans_tmp
print(ans) | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i, ai in enumerate(a):
ai_tmp = ai
while ai_tmp % 2 == 0:
ans += 1
ai_tmp >>= 1
print(ans) | p03325 |
eval(input());print((sum(bin(int(x))[::-1].index('1')for x in input().split()))) | _,a=open(0);print((sum(bin(int(x))[::-1].index('1')for x in a.split()))) | p03325 |
def resolve():
n = int(eval(input()))
ans = 0
a = list(map(int, input().split()))
for v in a:
while v%2 == 0:
v //= 2
ans += 1
print(ans)
return
if __name__ == "__main__":
resolve()
| def calc(x):
ans = 0
while (x % 2 == 0):
ans += 1
x //= 2
return ans
def resolve():
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for x in a:
ans += calc(x)
print(ans)
return
if __name__ == "__main__":
resolve()
| p03325 |
n = int(eval(input()))
a = list(map(int, input().split()))
a = sorted([i for i in a if i%2==0])
x = 0
ans = 0
while len(a)!=0 and a[-1]%2==0:
if a[x] % 2 != 0:
x += 1
a[x] = a[x]//2
ans += 1
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in a:
while i%2==0:
ans += 1
i = i//2
print(ans)
| p03325 |
n = int(eval(input()))
a = sorted(list(map(int,input().split())),reverse=True)
count = 0
while True:
cnt = 0
ccnt = 0
done = 0
for i in range(n):
if a[i] % 2 == 0:
if done == 0:
a[i] = a[i] // 2
cnt += 1
done += 1
... | n = int(eval(input()))
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
while a[i] % 2==0:
a[i] /= 2
cnt += 1
print(cnt)
| p03325 |
N = int(eval(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) | N = int(eval(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
... | p03325 |
n = int(eval(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)
| n=int(eval(input()))
a=list(map(int,input().split()))
c=0
for i in a:
while i%2==0:i,c=i/2,c+1
print(c) | p03325 |
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
for i in a:
t = i
while True:
if t % 2 == 0:
t //= 2
cnt += 1
else:
break
print(cnt)
| def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
cnt = 0
for i in range(n):
t = a[i]
while True:
if t % 2 == 0:
cnt += 1
t //= 2
el... | p03325 |
N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in range(10**9):
a.sort(reverse=True)
cnt = 0
for j in range(N):
if a[j]%2 == 0 and cnt == 0:
a[j] //= 2
cnt = 1
else:
a[j] *= 3
if cnt == 0:
print(ans)
... | N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in range(N):
while a[i] % 2 == 0:
a[i] //= 2
ans += 1
print(ans) | p03325 |
import math
n = int(eval(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:
... | import math
n = int(eval(input()))
li = [int(x) for x in input().split()]
ans = 0
isAvailable = False
for a in li:
if a % 2 == 0:
isAvailable = True
while(a % 2 == 0):
a /= 2
ans += 1
if isAvailable:
print(ans)
else:
print((0))
| p03325 |
n = int(eval(input()))
arr = list(map(int,input().split()))
ans = 0
def odd(arr):
for i in arr:
if i % 2 == 0:
return True
break
return False
while odd(arr):
maxOdd = max(list([x for x in arr if x % 2 == 0]))
arr[arr.index(maxOdd)] = arr[arr.index(maxOdd)] //... | n = int(eval(input()))
arr = list(map(int,input().split()))
ans = 0
def div(x):
cnt = 0
while x % 2 == 0:
x = x // 2
cnt += 1
return cnt
for i in arr:
if i % 2 == 0:
ans += div(i)
print(ans) | p03325 |
from copy import deepcopy
n = int(eval(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... | #!/usr/bin/env python
N = int(eval(input()))
A = [int(i) for i in input().split()]
ans = 0
for a in A:
while a % 2 != 1:
ans += 1
a /= 2
print(ans) | p03325 |
#!/usr/bin/env python
N = int(eval(input()))
A = [int(i) for i in input().split()]
ans = 0
for a in A:
while a % 2 != 1:
ans += 1
a /= 2
print(ans) | n = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for v in a:
while v%2 == 0:
ans += 1
v /= 2
print(ans) | p03325 |
input = open(0).read
N, *an = list(map(int, input().split()))
def main():
ans = 0
for i in range(N):
tmp = 0
while an[i]:
if an[i] % 2:
break
else:
tmp += 1
an[i] //= 2
ans += tmp
print(a... | def main():
N, *a = list(map(int, open(0).read().split()))
print((sum([bin(ai)[::-1].index("1") for ai in a])))
return
main()
| p03325 |
N = int(eval(input()))
A = list(map(int,input().split()))
SUM = 0
for i in A:
count = 0
while i%2 == 0:
i = i/2
count += 1
SUM+=count
print(SUM) | N = int(eval(input()))
A = list(map(int,input().split()))
SUM = 0
for i in A:
count = 0
while i%2 == 0:
i//=2
count += 1
SUM+=count
print(SUM) | p03325 |
lst = [2184, 2126, 1721, 1800, 1024, 2528, 3360, 1945, 1280, 1776]
n = eval(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):
coun... | n = eval(input())
lst = [int(e) for e in input().split()]
count = 0
m = 0
f = True
while(f):
f = False
for i in range(m,len(lst)):
if(lst[i]%2 == 0):
m = i
f = True
break
if(f):
count += 1
else:
break
lst[m] = int(lst[m]... | p03325 |
n = int(input())
m = list(map(int, input().split()))
total = 0
for i in range(n):
x = m[i]
while True:
if x % 2 == 1:
break
total += 1
x = x // 2
print(total) | def meu_map(l):
for i in range(len(l)):
l[i] = int(l[i])
n = int(input())
array = input().split()
meu_map(array)
fatores = 0
for e in array:
while e != 1:
if e % 2 == 0:
e /= 2
fatores += 1
else:
break
print(fatores) | p03325 |
import os, sys, re, math
n = int(eval(input()))
a = list(map(int,input().split(' ')))
cnt = 0
while True:
a.sort(reverse=True)
if (sum([x % 2 for x in a])) == n:
break
flg = False
for i in range(n):
if a[i] % 2 == 0 and flg == False:
a[i] = a[i] // 2
... | import os, sys, re, math
n = int(eval(input()))
a = list(map(int,input().split(' ')))
cnt = 0
for ai in a:
while ai % 2 == 0:
cnt += 1
ai = ai // 2
print(cnt)
| p03325 |
import sys
sys.stdin.readline()
a = list(map(int, sys.stdin.readline().split()))
a = [x for x in a if x % 2 == 0]
cnt = 0
while a:
a.sort(reverse=True)
if a[0] % 2 == 0:
a[0] //= 2
if a[0] % 2 != 0:
del a[0]
cnt += 1
else:
break
print(cnt) | import math
import sys
sys.stdin.readline()
a = list(map(int, sys.stdin.readline().split()))
a = [x for x in a if x % 2 == 0]
cnt = 0
for x in a:
while x % 2 == 0:
x //= 2
cnt += 1
print(cnt) | p03325 |
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 ... | from collections import Counter
def prime_factorize(n):
a = 0
while n % 2 == 0:
a += 1
n //= 2
return a
N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in a:
ans += prime_factorize(i)
print(ans) | p03325 |
N = int(eval(input()))
a = list(map(int,input().split()))
result = 0
for i in a:
while True:
if i%2!=0:
break
else:
i/=2
result += 1
print(result) | n = int(eval(input()))
a = list(map(int,input().split()))
p = 0
for i in a:
cnt = 0
while i % 2 == 0:
cnt += 1
i //= 2
p += cnt
print(p)
| p03325 |
N = int(eval(input()))
A = list(map(int, input().split()))
e = 0
for a in A:
while a&1 == 0:
e += 1
a >>= 1
print(e) | N = int(eval(input()))
A = list(map(int, input().split()))
e = 0
for a in A:
l = 0
over = a.bit_length()
while over - l > 1:
m = (l+over) // 2
if a % (1<<m) == 0: l = m
else: over = m
e += l
print(e) | p03325 |
n = int(eval(input()))
ni = list(map(int, input().split()))
cnt = 0
for i in ni:
while not i % 2:
i /= 2
cnt += 1
print(cnt) | N = int(eval(input()))
a = list(map(int, input().split()))
def f(n):
cnt = 0
while(n%2==0):
n = n//2
cnt +=1
return cnt
total = 0
for e in a:
total += f(e)
print(total) | p03325 |
n = int(eval(input()))
ni = list(map(int, input().split()))
cnt = 0
for i in ni:
while (i % 2==0):
i /= 2
cnt += 1
print(cnt)
| n = int(eval(input()))
ni = list(map(int, input().split()))
cnt = 0
for i in ni:
while ( i % 2==0):
i //= 2
cnt += 1
print(cnt)
| p03325 |
n = int(eval(input()))
ni = list(map(int, input().split()))
cnt = 0
for i in ni:
while ( i % 2==0):
i //= 2
cnt += 1
print(cnt)
| n = int(eval(input()))
ni = list(map(int, input().split()))
def f(i):
cnt = 0
while not i%2:
i //= 2
cnt += 1
return cnt
total = 0
for i in ni:
total += f(i)
print(total)
| p03325 |
n = int(eval(input()))
ni = list(map(int, input().split()))
total = 0
for i in ni:
while not i%2:
i //= 2
total += 1
print(total) | if __name__ == '__main__':
n = int(eval(input()))
ni = list(map(int, input().split()))
total = 0
for i in ni:
while not i%2:
i //= 2
total += 1
print(total) | p03325 |
n = int(eval(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)
| n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(n):
x = 0
ai = a[i]
while(ai%2==0):
ai = ai//2
x+=1
ans+=x
print(ans)
| p03325 |
N, *a = list(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:
... | N, *a = list(map(int, open(0).read().split()))
ans = 0
for i in range(N):
ans += len(bin(a[i])) - bin(a[i]).rfind('1') - 1
print(ans)
| p03325 |
N, *a = list(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
... | N, *a = list(map(int, open(0).read().split()))
ans = 0
for i in range(N):
while a[i] % 2 == 0:
a[i] //= 2
ans += 1
print(ans)
| p03325 |
answer = 0
N = int(eval(input()))
A = list(map(int,input().split()))
for i in range(N) :
while A[i] % 2 == 0 :
A[i] = A[i] / 2
answer += 1
print(answer)
| N = int(eval(input()))
L = list(map(int,input().split()))
ans = 0
for i in range(N) :
flag = 0
while flag == 0 :
if (L[i] % 2) == 0 :
ans += 1
L[i] = L[i]//2
else :
flag = 1
print(ans)
| p03325 |
N = int(eval(input()))
L = list(map(int,input().split()))
ans = 0
for i in range(N) :
flag = 0
while flag == 0 :
if (L[i] % 2) == 0 :
ans += 1
L[i] = L[i]//2
else :
flag = 1
print(ans)
| N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(len(A)) :
while True :
if A[i] % 2 != 0 :
break
ans += 1
A[i] //= 2
print(ans)
| p03325 |
iN = int(eval(input()))
def parse2(a):
i = 0
while a % 2 == 0:
i+=1
a //= 2
return i
print((sum([parse2(int(_)) for _ in input().split()])))
| iN = int(eval(input()))
def parse2(a):
i = 0
while a % 2 == 0:
i+=1
a >>= 1
return i
print((sum(parse2(_) for _ in map(int,input().split()))))
| p03325 |
n = int(eval(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
... | import math
n = int(eval(input()))
A = [int(s) for s in input().split()]
i = 0
flag = 0
count = 0
sum = 0
def bynum(x):
count = 0
while True:
if x % 2 == 0:
x = x / 2
count += 1
else:
return count
for a in A:
sum += bynum(a)
print(sum)
"""
while... | p03325 |
N = int(eval(input()))
A = list(map(int,input().split()))
cnt = 0
for a in A:
while a%2 == 0:
a //= 2
cnt += 1
print(cnt) | N = int(eval(input()))
A = list(map(int,input().split()))
cnt = 0
for a in A:
#print(format(a,'b')[::-1])
#print(format(a,'b')[::-1].index('1'))
cnt += format(a,'b')[::-1].index('1')
print(cnt) | p03325 |
def log2(n):
n = int(n)
cnt = 0
while ~n & 1:
cnt += 1
n >>= 1
return cnt
N = int(eval(input()))
print((sum(map(log2, input().split()))))
| def log2(n):
cnt = 0
while n % 2 == 0:
cnt += 1
n //= 2
return cnt
N = int(eval(input()))
print((sum([log2(int(x)) for x in input().split()]))) | p03325 |
N = int(eval(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 ... | N = int(eval(input()))
a = list(map(int, input().split()))
def factorization(n):
cnt = 0
while n%2==0:
n /= 2
cnt += 1
return cnt
fac = [0] * N
for i in range(N):
if a[i]%2==0:
fac[i] = factorization(a[i])
print((sum(fac))) | p03325 |
# -*- coding: utf-8 -*-
def can_div2(a):
for i in range(len(a)):
if a[i] % 2 == 0:
a[i] /= 2
return True
else:
return False
N = int(eval(input()))
a = list(map(int, input().split()))
c = 0
while(can_div2(a)):
c += 1
print(c) | # -*- coding: utf-8 -*-
N = int(eval(input()))
a = list(map(int, input().split()))
c = 0
for i in range(N):
while a[i] % 2 == 0:
a[i] /= 2
c += 1
print(c) | p03325 |
import sys
input = sys.stdin.readline
import math
import random
class Prime:
seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
def is_prime(self, n):
"""
prime test (hybrid)
see also: https://qiita.com/gushwell... | N = int(eval(input()))
A = tuple(map(int,input().split()))
n2= 0
for num in A:
while num%2 == 0:
n2 += 1
num /= 2
else:
print(n2) | p03325 |
from functools import reduce
n = int(eval(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) | n = int(eval(input()))
nums = list(map(int, input().split()))
iters = 0
count = 0
while len(nums) != 0:
size = len(nums)
nums = list([x//2 for x in list([x for x in nums if x%2 == 0])])
count += (size - len(nums))*iters
iters += 1
print(count) | p03325 |
N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(N):
while a[i] % 2 == 0:
a[i] /= 2
ans += 1
print(ans) | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(N):
while a[i] % 2 == 0:
a[i] //= 2
ans += 1
print(ans) | p03325 |
#!/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:
pri... | #!/usr/bin/env python3
import sys
INF = float("inf")
import math
import collections
def solve(N: int, a: "List[int]"):
print((int(sum([math.log2(v & -v) for v in a]))))
return
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
... | p03325 |
n=int(eval(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:
p... | n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in range(n):
while a[i]%2==0:
a[i]=a[i]//2
ans+=1
print(ans) | p03325 |
n, *a = list(map(int, open(0).read().split()))
count = 0
for i in a:
if i % 2 == 0:
while i % 2 == 0:
if i % 2 == 0:
count += 1
i //= 2
else:
break
print(count) | n, *a = list(map(int, open(0).read().split()))
count = 0
for i in a:
while i % 2 == 0:
count += 1
i //= 2
print(count) | p03325 |
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
while any(A[i] % 2 == 0 for i in range(n)):
count = 0
for i in range(n):
if A[i] % 2 == 0:
if count == 0:
A[i] = A[i] // 2
count += 1
else:
... | n = int(eval(input()))
A = list(map(int, input().split()))
A2 = []
for i in range(n):
if A[i] % 2 == 0:
A2.append(A[i])
count = 0
for a in A2:
while a % 2 == 0:
a = a // 2
count += 1
print(count) | p03325 |
N = int(eval(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) | N = int(eval(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:
break
ans += cnt
print(ans) | p03325 |
N = int(eval(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:
break
ans += cnt
print(ans) | N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for a in A:
while a % 2 == 0:
a //= 2
ans += 1
print(ans) | p03325 |
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 = int(eval(input()))
li = list(map(int,input().split()))
point = 0
for i in li:
while i%2 == 0:
i //= 2
point += 1
print(point) | p03325 |
#全ての要素を奇数にできれば良い
#2で何回割れるか
n=int(eval(input()))
a=[int(i) for i in input().split()]
k=0
while True:
f=0
for i in range(n):
if a[i]%2==0:
k+=1
f=1
a[i]=a[i]//2
if f==0:
break
print(k)
| n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in range(n):
while a[i]%2==0:
ans+=1
a[i]//=2
print(ans) | p03325 |
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(n):
while a[i]%2 == 0:
ans += 1
a[i] //= 2
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in a:
while i%2 == 0:
ans += 1
i //= 2
print(ans) | p03325 |
N = int(eval(input()))
a = list(map(int, input().rstrip().split()))
even = [i for i in a if i%2 == 0]
count = 0
for i in even:
c = 0
for j in range(100):
rem = i % 2
i //= 2
if rem == 1:
break
c += 1
count += c
print(count) | N = int(eval(input()))
a = list(map(int, input().rstrip().split()))
even = [i for i in a if i%2 == 0]
count = 0
for i in even:
c = 0
while True:
rem = i % 2
i //= 2
if rem == 1:
break
c += 1
count += c
print(count) | p03325 |
N = int(eval(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 ... | N = int(eval(input()))
a = list(map(int, input().split()))
count = 0
for i in a:
while i % 2 == 0:
i //= 2
count += 1
print(count) | p03325 |
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in a:
while True:
if i%2!=0:
break
ans+=1
i/=2
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for a in A:
while a % 2 == 0:
if not a:
break
ans += 1
a //= 2
print(ans)
| p03325 |
#!/usr/bin/env python3
n = int(eval(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)==Fa... | #!/usr/bin/env python3
n = int(eval(input()))
a = list(map(int, input().split()))
def f(n):
ans = 0
while n%2 == 0:
n //= 2
ans += 1
return ans
ans = 0
for i in a:
ans += f(i)
print(ans)
| p03325 |
board = [[False]*1000001]*1000001
while True:
m = int(eval(input()))
if m == 0: break
star = tuple(tuple(map(int, input().split())) for i in range(m))
sx, sy = star[0]
n = int(eval(input()))
starlist = [tuple(map(int, input().split())) for i in range(n)]
for i in range(n):
... | board = [[False]*1000001]*1000001
while True:
m = int(eval(input()))
if m == 0: break
star = list(set(tuple(tuple(map(int, input().split())) for i in range(m))))
sx, sy = star[0]
n = int(eval(input()))
starlist = list(set([tuple(map(int, input().split())) for i in range(n)]))
f... | p00447 |
while True:
try:
a,da, b = [], [], []
m = int(input())
for i in range(m):
a.append(list(map(int, input().split())))
a = sorted(a)
dax,day = [],[]
for i in range(m):
dax.append(a[i][0]-a[0][0])
day.append(a[i][1]-a[0][1])
... | while True:
try:
a,da, b = [], [], []
m = int(input())
for i in range(m):
a.append(list(map(int, input().split())))
a = sorted(a)
dax = []
for i in range(m):
dax.append(a[i][0]-a[0][0])
n = int(input())
for i in range... | p00447 |
while True:
try:
dax,bx = [],[]
m = int(input())
a = sorted([list(map(int, input().split())) for i in range(m)])
for i in range(m):
dax.append(a[i][0]-a[0][0])
n = int(input())
b = sorted([list(map(int, input().split())) for i in range(n)])
... | while True:
try:
m = int(input())
a = sorted([list(map(int, input().split())) for i in range(m)])
dax = [a[i][0]-a[0][0] for i in range(m)]
n = int(input())
b = sorted([list(map(int, input().split())) for i in range(n)])
bx = [b[i][0] for i in range(n)]
... | p00447 |
while 1:
n = eval(input())
if n == 0: break
p = sorted([list(map(int, input().split())) for i in range(n)])
d = [[p[i][0] - p[0][0], p[i][1] - p[0][1]] for i in range(1,n)]
m = eval(input())
q = sorted([list(map(int, input().split())) for i in range(m)])
for p1 in q:
for i in... | while 1:
n = eval(input())
if n == 0: break
p = set([tuple(map(int, input().split())) for i in range(n)])
m = eval(input())
q = set([tuple(map(int, input().split())) for i in range(m)])
ret = False
for px, py in p:
if ret: break
for qx, qy in q:
if ret: ... | p00447 |
while 1:
m=int(input())
if m==0:break
st=[list(map(int,input().split())) for _ in range(m)]
n=int(input())
pi=[list(map(int,input().split())) for _ in range(n)]
d=[[st[i][0]-st[0][0],st[i][1]-st[0][1]] for i in range(1,m)]
for i in range(n):
mo=[[pi[j][0]-pi[i][0],pi[j][1]-pi... | while 1:
m=int(input())
if m==0:break
st=[list(map(int,input().split())) for _ in range(m)]
n=int(input())
pi=[list(map(int,input().split())) for _ in range(n)]
d=[[st[i][0]-st[0][0],st[i][1]-st[0][1]] for i in range(1,m)]
for i in range(n):
mo=[[pi[j][0]-pi[i][0],pi[j][1]-pi... | p00447 |
N = int(eval(input()))
def grundy(x, k):
while x % k != 0:
p = max(1, (x - x // k * k) // (x // k + 1))
x = x - (x // k + 1) * p
return x // k
g = 0
for _ in range(N):
a, k = list(map(int, input().split()))
g ^= grundy(a, k)
print(('Takahashi' if g != 0 else 'Aoki')) | N = int(eval(input()))
g = 0
for _ in range(N):
x, k = list(map(int, input().split()))
while x % k != 0:
x = x - (x // k + 1) * max(1, (x - x // k * k) // (x // k + 1))
g ^= x // k
print(('Takahashi' if g != 0 else 'Aoki')) | p03422 |
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in ... | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in ... | p03422 |
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, ... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, ... | p03422 |
def main():
import sys
input = sys.stdin.readline
N = int(eval(input()))
win = 0
for _ in range(N):
a, k = list(map(int, input().split()))
while True:
if a < k:
g = 0
break
elif a % k == 0:
g = a //... | def main():
import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
win = 0
for _ in range(N):
a, k = list(map(int, input().split()))
while True:
if a < k:
g = 0
break
elif a % k == 0:
g... | p03422 |
while True:
a,b,c = input().split()
if b=='?':
break
elif b =='+':
d = int(a) + int(c)
elif b=='-':
d = int(a) - int(c)
elif b=='*':
d = int(a)*int(c)
else :
d = int(a)/int(c)
print((int(d))) | while True:
Input = input().split()
a = int(Input[0])
op = Input[1]
b = int(Input[2])
if op == '?':
break
if op == '+':
print((a+b))
elif op == '-':
print((a-b))
elif op == '*':
print((a*b))
else:
print((a//b))
| p02401 |
answers=[]
while True:
iquation=[]
iquation=input().split()
iquation[0]=int(iquation[0])
iquation[2]=int(iquation[2])
if iquation[1]=='+':
answers.append(iquation[0]+iquation[2])
elif iquation[1]=='-':
answers.append(iquation[0]-iquation[2])
elif iquation[1]=='*':
... | while True:
a,op,b=input().split()
a=int(a)
b=int(b)
if op=="+":
print((a+b))
elif op=="-":
print((a-b))
elif op=="*":
print((a*b))
elif op=="/":
print((a//b))
elif op=="?":
break | p02401 |
while True:
a,op,b=input().split()
if op=='?': break
elif op=='+': print(( int(a) + int(b) ))
elif op=='-': print(( int(a) - int(b) ))
elif op=='*': print(( int(a) * int(b) ))
elif op=='/': print(( int(a) // int(b) )) | while True:
a,op,b=input().split()
if op=='?': break
eval("print( int(int(a) {0} int(b)) )".format(op)) | p02401 |
while 1:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == "?":
break
elif op == "+":
print((a + b))
elif op == "-":
print((a - b))
elif op == "*":
print((a * b))
elif op == "/":
print((int(a / b)))
| op = ""
while op != "?":
a, op, b = input().split()
a = int(a)
b = int(b)
if op == "+":
print((a + b))
elif op == "-":
print((a - b))
elif op == "*":
print((a * b))
elif op == "/":
print((int(a / b)))
elif op == "?":
break | p02401 |
h=int(eval(input()))
w=int(eval(input()))
n=int(eval(input()))
if w>=h:
if n%w==0:
print((n//w))
else:
print((n//w+1))
else:
if n%h==0:
print((n//h))
else:
print((n//h+1)) | h=int(eval(input()))
w=int(eval(input()))
n=int(eval(input()))
mx=max(h,w)
if n%mx==0:
print((n//mx))
else:
print((n//mx+1)) | p02795 |
H = int(eval(input()))
W = int(eval(input()))
N = int(eval(input()))
HW =H*W
ans =H+W
for h in range(0,H+1):
for w in range(0,W+1):
cntB = HW - (H-h)*(W-w)
if cntB>=N:
ans = min(ans, h+w)
print(ans) | h,w,n=int(eval(input())),int(eval(input())),int(eval(input()))
a=max(h,w)
print(((n+a-1)//a))
| p02795 |
import math
H = int(eval(input()))
W = int(eval(input()))
N = int(eval(input()))
n = max(H,W)
print((math.ceil(N/n))) | H = int(eval(input()))
W = int(eval(input()))
N = int(eval(input()))
a = max(H,W)
n = N//a
if N%a==0:
print(n)
else:
print((n+1)) | p02795 |
H = int(eval(input()))
W = int(eval(input()))
N = int(eval(input()))
a = max(H, W)
c = 0
ans = 0
while N > c:
c += a
ans += 1
print(ans)
| H = int(eval(input()))
W = int(eval(input()))
N = int(eval(input()))
a = max(H, W)
print(((N+a-1)//a))
| p02795 |
from math import ceil
H = int(eval(input()))
W = int(eval(input()))
N = int(eval(input()))
print((ceil(N/(max(W, H)))))
| H, W, N = int(eval(input())), int(eval(input())), int(eval(input()))
print(((N+max(H, W)-1)//max(H, W)))
| p02795 |
import heapq
from itertools import chain
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
r = 0
for i in range(1, min(n, k) + 1):
for j in range(i):
s = 0
h = []
for m in chain(list(range(i - j)), list(range(n - j, n))):
x = v[m]
s +=... | from itertools import chain
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
r = 0
for i in range(1, min(n, k) + 1):
for j in range(i):
r1, r2 = list(range(i - j)), list(range(n - j, n))
s = sum(v[m] for m in chain(... | p03032 |
from itertools import chain
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
r = 0
for i in range(1, min(n, k) + 1):
for j in range(i):
r1, r2 = list(range(i - j)), list(range(n - j, n))
s = sum(v[m] for m in chain(... | from itertools import chain
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
r = 0
for i in range(1, min(n, k) + 1):
for j in range(i):
r1, r2 = i - j, n - j
s = sum(v[m] for m in chain(list(range(r1)), list(range(r... | p03032 |
from itertools import chain
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
r = 0
for i in range(1, min(n, k) + 1):
for j in range(i):
r1, r2 = i - j, n - j
s = sum(v[m] for m in chain(list(range(r1)), list(range(r... | from itertools import chain, islice
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(v[m] for m in chain(list(range(i - j)), list(range(n - j, n)))) -
sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i)... | p03032 |
from itertools import chain, islice
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(v[m] for m in chain(list(range(i - j)), list(range(n - j, n)))) -
sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i)... | from itertools import islice
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(v[:i - j] + v[n - j:]) -
sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i))
for i in range(1, min(n, k) + 1) fo... | p03032 |
from itertools import chain, islice
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(chain(v[:i - j], v[n - j:])) -
sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i))
for i in range(1, min(... | R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(v[:i - j] + v[n - j:]) -
sum([x for x, m in a if m < i - j or m >= n - j][:k - i])
for i in range(1, min(n, k) + 1) for j in range(i))
print(ans)
| p03032 |
R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(v[:i - j] + v[n - j:]) -
sum([x for x, m in a if m < i - j or m >= n - j][:k - i])
for i in range(1, min(n, k) + 1) for j in range(i))
print(ans)
| R = lambda: list(map(int, input().split()))
n, k = R()
v = list(R())
ans = max(sum(v[:i - j] + v[n - j:]) -
sum(sorted(x for x in v[:i - j] + v[n - j:] if x < 0)[: k - i])
for i in range(1, min(n, k) + 1) for j in range(i))
print(ans)
| p03032 |
N,K=list(map(int,input().split()))
V=list(map(int,input().split()))
r=min(N,K)
ans=0
for a in range(r+1):
for b in range(r-a+1):
tmp,minus=0,[]
for i in range(a):
t=V[i]
tmp+=t
if t<0:
minus.append(t)
for j in range(b):
... | N,K=list(map(int,input().split()))
V=list(map(int,input().split()))
r,ans=min(N,K),0
for a in range(r+1):
for b in range(r-a+1):
tmp,minus=0,[]
for i in range(a):
tmp+=V[i]
if V[i]<0:
minus.append(V[i])
for j in range(b):
tmp+=V[N-j-1]
if V[N-j-1]<0:
mi... | p03032 |
from heapq import heappush, heappop, heapify
N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
# N jewels in dequeue D
# at most K operations
# 1 <= N <= 50
# 1 <= K <= 100
# -10000000 <= Vi <= 10000000
# Operation A, B: Remove left or right
# Operation C, D: Add to left or right... | from heapq import heappush, heappop, heapify
N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
# N jewels in dequeue D
# at most K operations
# 1 <= N <= 50
# 1 <= K <= 100
# -10000000 <= Vi <= 10000000
# Operation A, B: Remove left or right
# Operation C, D: Add to left or right... | p03032 |
# encoding:utf-8
import copy
import random
import bisect #bisect_left これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
N,K = list(map(int,input().split()))
V = [int(i) for i in input().split()]
#
if N == 1:
print((m... | # encoding:utf-8
import copy
import random
import bisect #bisect_left これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
N,K = list(map(int,input().split()))
V = [int(i) for i in input().split()]
#
# if N == 1:
# prin... | p03032 |
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:05 2019
@author: Yamazaki Kenichi
"""
import heapq
N,K = list(map(int,input().split()))
V = list(map(int,input().split()))
def a(K):
if K > N:
return N
else:
return K
ans = 0
for i in range(K):
for j in range(a(K-... | # -*- coding: utf-8 -*-
"""
Created on Wed May 29 22:59:58 2019
@author: Yamazaki Kenichi
"""
N, K = list(map(int,input().split()))
V = list(map(int,input().split()))
ans = 0
for pickup_n in range(min(K, N)+1):
for start in range(pickup_n + 1):
tmp = [0]
for i in range(pickup_n):
... | p03032 |
import heapq
n,k=list(map(int,input().split()))
v=list(map(int,input().split()))
s=-10**7-1
if n>k:
for l in range(k//2+1):
for i in range(k+1-l):
d=v[:i]
d.extend(v[(n-k+l+i):])
heap=heapq.heapify(d)
res=sum(d)
for j in range(l):
... | import heapq
res=0
n,k=list(map(int,input().split()))
v=list(map(int,input().split()))
r=min(n,k)
for a in range(r+1):#操作Aの回数
for b in range(r-a+1):#Bの回数
d=v[:a]
d.extend(v[n-b:])
s=sum(d)
heapq.heapify(d)
l=k-(a+b) #捨てる回数print(d)
for _ in range(l):
... | p03032 |
import heapq
from collections import deque
from copy import deepcopy
n,k = list(map(int,input().split()))
U = deque(list(map(int,input().split())))
Max = -10**9
for a in range(min(n,k)+1):
for b in range(min(n,k)+1-a):
V = deepcopy(U)
Heap = []
heapq.heapify(Heap)
if a >= ... | N,K = list(map(int,input().split()))
V = list(map(int,input().split()))
cum = [0]
rcum = [0]
for i in range(N):
cum.append(cum[-1]+V[i])
rcum.append(rcum[-1]+V[-1-i])
ans = 0
for i in range(N+1):
for j in range(N+1):
if i+j > min(N,K):
continue
value = cum... | p03032 |
N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
ans = 0
for l_pop in range(K + 1):
for r_pop in range(K + 1):
X = []
if (l_pop + r_pop > K) or (l_pop + r_pop > N):
continue
else:
X.extend(V[:l_pop])
X.extend(V[::-1][:... | N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
# 最終的に「持っているもの」の価値の合計を高めたい
# Dから取り出すことをpop、Dに詰めることをenqueueとする
ans = 0
for pop_cnt in range(K + 1):
enqueue_cnt = K - pop_cnt
if pop_cnt > N:
continue
for l in range(pop_cnt + 1):
holding = []
... | p03032 |
# ABC128D - equeue
# exhaustive search
def main():
N, K = tuple(map(int, input().rstrip().split()))
V = tuple(map(int, input().rstrip().split()))
lim = min(N, K)
ans = set()
for l in range(N + 1):
for r in range(N + 1):
if l + r > lim:
break
... | # D - equeue
def main():
N, K, *V = list(map(int, open(0).read().split()))
lim = min(N, K)
available_choices = set()
for l in range(lim + 1):
for r in range(lim + 1):
if l + r > lim:
break
choice = V[:l] + V[-r:] if r else V[:l]
c... | p03032 |
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
V = [int(x) for x in input().split()]
ans = 0
for i in range(K + 1):
for j in range(K + 1 - i):
for k in range(K + 1 - i - j):
tmp = list()
tmp.extend(V[:min(i, N)])
tmp.extend(V[ma... | import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
V = [int(x) for x in input().split()]
ans = 0
for i in range(K + 1):
for j in range(K + 1 - i):
k = K - i - j
tmp = list()
tmp.extend(V[:min(i, N)])
tmp.extend(V[max(i, N - j):N])
tmp.... | p03032 |
import heapq, copy
n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
ans = -10 ** 10
for a in range(min(n, k) + 1):
have = []
for i in range(a):
have.append(v[i])
o_have = copy.deepcopy(have)
for b in range(min(n, k) - a + 1):
for i in range(b):
... | import heapq, copy
n, k = list(map(int, input().split()))
v = list(map(int, input().split()))
ans = -10 ** 10
for a in range(min(n, k) + 1):
for b in range(min(n, k) - a + 1):
have = []
for i in range(a):
have.append(v[i])
for i in range(b):
have.a... | p03032 |
# coding: utf-8
import sys
input = sys.stdin.readline
# N = int(input())
N, K = list(map(int, input().split()))
D = [int(x) for x in input().split()]
# S = input()
ans = 0
for l in range(N + 1):
if l > K:
break
for r in range(N - l + 1):
if l + r > K:
break
... | # coding: utf-8
import sys
input = sys.stdin.readline
# N = int(input())
N, K = list(map(int, input().split()))
D = [int(x) for x in input().split()]
# S = input()
ans = 0
for l in range(N + 1):
if l > K:
break
for r in range(N - l + 1):
if l + r > K:
break
... | p03032 |
# coding: utf-8
import sys
input = sys.stdin.readline
# N = int(input())
N, K = list(map(int, input().split()))
D = [int(x) for x in input().split()]
# S = input()
ans = 0
for l in range(N + 1):
if l > K:
break
for r in range(N - l + 1):
if l + r > K:
break
... | # coding: utf-8
import sys
input = sys.stdin.readline
# N = int(input())
N, K = list(map(int, input().split()))
D = [int(x) for x in input().split()]
# S = input()
ans = 0
for l in range(N + 1):
if l > K:
break
for r in range(N - l + 1):
if l + r > K:
break
... | p03032 |
N,K = list(map(int,input().split()))
V = [0] + list(map(int,input().split())) + [0]
m = min(N,K)
A = []
ans = 0
#左からi個、右からj個除いた時の宝石の価値のmax
for i in range(m+1):
if i == 0:
pass
else:
A.append(V[i])
B = []
for j in range(m-i+1):
if j == 0:
pass
... | import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def ... | p03032 |
import heapq
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
def heap_push(my_lst, a):
heapq.heappush(my_lst, a)
return my_lst
def dfs(k, lst, my_lst):
if k == 0:
return max(sum(my_lst), 0)
if len(my_lst) == 0:
a = dfs(k-1, lst[1:], he... | n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
res = 0
max_num = min(n, k)
for i in range(max_num+1):
for j in range(max_num+1 - i):
my_lst = []
my_lst += lst[:i]
if j != 0:
my_lst += lst[-j:]
s = sum(my_lst)
so... | p03032 |
from collections import deque
n, k = list(map(int, input().split()))
vs_ = deque(list(map(int, input().split())))
max_v = 0
import copy
for a in range(k+1):
for b in range(k+1-a):
for c in range(k+1-a-b):
vs = copy.copy(vs_)
us = []
for x in range(a):
if vs:
... | n, k = list(map(int, input().split()))
V = list(map(int, input().split()))
from collections import deque
V = deque(V)
import copy
ans = -10**18
for i in range(k+1):
for j in range(k+1):
if i+j > k:
continue
if i+j > n:
continue
V_ = copy.copy(V)
... | p03032 |
import bisect
N, K = list(map(int, input().split()))
V = [int(i) for i in input().split()]
ans = 0
for a in range(min(N, K)+1):
for b in range(min(N, K)-a+1):
score = 0
D = sorted(V[:a]+V[N-b:])
score = sum(D[min(K-(a+b), bisect.bisect_left(D, 0)):])
# print(score)
... | import bisect
N, K = list(map(int, input().split()))
V = [int(i) for i in input().split()]
ans = -10**20
for l in range(min(K+1, N+1)):
for r in range(min(K-l+1, N-l+1)):
P = V[:l]+V[N-r:]
P.sort()
z = bisect.bisect_left(P, 0)
if z <= K-l-r:
ans = max(ans,... | p03032 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.