Problem:


Score : 600 points

Problem Statement

A tetromino is a figure formed by joining four squares edge to edge.
We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:

Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession are a_I, a_O, a_T, a_J, a_L, a_S and a_Z, respectively.
Snuke will join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide.
Here, the following rules must be followed:

When placing each tetromino, rotation is allowed, but reflection is not.

Each square in the rectangle must be covered by exactly one tetromino.

No part of each tetromino may be outside the rectangle.

Snuke wants to form as large a rectangle as possible.
Find the maximum possible value of K.

Constraints

0≤a_I,a_O,a_T,a_J,a_L,a_S,a_Z≤10^9

a_I+a_O+a_T+a_J+a_L+a_S+a_Z≥1

Input

The input is given from Standard Input in the following format:

a_I a_O a_T a_J a_L a_S a_Z

Output

Print the maximum possible value of K. If no rectangle can be formed, print 0.

Sample Input 1

2 1 1 0 0 0 0

Sample Output 1

3

One possible way to form the largest rectangle is shown in the following figure:

Sample Input 2

0 0 10 0 0 0 0

Sample Output 2

0

No rectangle can be formed.



Sample input:
2 1 1 0 0 0 0


Sample output:
3

Submission status: Wrong Answer

Solution code:
I, O, T, J, L, S, Z = list(map(int, input().split()))
a = O
a += (I >> 1) << 1
a += (J >> 1) << 1
a += (L >> 1) << 1
if I & 1 and J & 1 and L & 1:
    a += 3

print(a)

Submission status: Wrong Answer

Solution code:
A = [int(i) for i in input().split()]
B = [A[1],A[0],A[3],A[4]]
if max(B) == 1 and B[0] == 0:
	print(0)
else:
	print(B)
	ans = 0
	ans += B[0]
	if not sum([i%2 for i in B[1:]])%3:
		ans += sum(B[1:])
	else:
		ans += sum(B[1:])-1
	print(ans)

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())

print(int(aI/2)*2+aO+int(aJ/2)*2+int(aL/2)*2+min(aI%2, min(aJ%2, aL%2))*3)

Submission status: Wrong Answer

Solution code:
I, O, T, J, L, S, Z = list(map(int, input().split()))
a = O
a += (I >> 1) << 1
a += (J >> 1) << 1
a += (L >> 1) << 1
if I & 1 and J & 1 and L & 1:
    a += 1

print(a)

Submission status: Wrong Answer

Solution code:
I,O,T,J,L,S,Z=map(int,raw_input().split())
ans=0
ans+=2*O
JL=abs(J-L)
ans+=6*min(JL,I)
I-=JL
if I>=0:
    ans+=4*(I/2)
else:
    JL-=I
    ans+=4*JL
print(ans/2)

Submission status: Wrong Answer

Solution code:
i, o, t, j, l, s, z = map(int, raw_input().split())

ans = o
if j % 2 != 0 and l % 2 != 0 and i > 0:
    j -= 1
    l -= 1
    i -= 1
    ans += 3

if j % 2 == 0:
    ans += j
    j = 0
else:
    ans += j-1
    j = 1

if l % 2 == 0:
    ans += l
    l = 0
else:
    ans += l-1
    l = 1

if i % 2 == 0:
    ans += i
else:
    ans += i-1

print ans

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
b = a[:]

def aa(a):
    total = a[1]
    i6 = max(min(a[0],a[3],a[4]) - 1, 0)
    a[0] -= i6
    a[3] -= i6
    a[4] -= i6
    if a[3]%2 == 0 and a[4]%2 == 0:
        pass
    else:
        i6 += 1
        a[0] -= 1
        a[3] -= 1
        a[4] -= 1
    total += i6 * 3
    total += a[0] //2*2
    total += a[3]//2 *2
    total += a[4]//2 *2
    return total

def bb(a):
    total = a[1]
    total += a[0]//2 * 2
    total += a[3]//2 * 2
    total += a[4]//2 * 2
    if a[0] % 2 == 1 and a[3]%2==0 and a[4]%2 ==0:
        total += 3
    return total

print(max(aa(a),bb(b)))

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f, g = map(int, raw_input().split())
print a/2*2 + b + d/2*2 + e/2*2

Submission status: Wrong Answer

Solution code:
I,O,T,J,L,S,Z=map(int,raw_input().split())
ans=0
ans+=2*O
JL=abs(J-L)
ans+=6*min(JL,I)
I-=JL
if I>0:
    ans+=4*(I/2)
print(ans/2)

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())

t = min([aJ, aL, aI])
s = min([aJ - t, aL - t])
print(3 * t + 2 * s + (aI - t) // 2 * 2 + aO)

Submission status: Wrong Answer

Solution code:
I, O, T, J, L, S, Z = list(map(int, input().split()))
print((I >> 1) * 2 + O + (J >> 1) * 2 + (L >> 1) * 2)

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())

t = min([aJ, aL, aI])
s = min([aJ - 1, aL - 1])
print(3 * t + 2 * s + (aI - t) // 2 * 2 + aO)

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())

t = min([aJ, aL, aI])
print(3 * t + (aI - t) // 2 * 2 + aO)

Submission status: Wrong Answer

Solution code:
def solve():
    ia, oa, ta, ja, la, sa, za = map(int, input().split())
    ans = 0
    object_min = min(ia, ja, la) 
    ans += object_min * 3
    ans += oa
    ans += max(0, (ia - object_min) // 2 * 2)
    ans += max(0, (min(ja, la) - object_min) * 2)
    print(ans)

if __name__=="__main__":
    solve()

Submission status: Wrong Answer

Solution code:
i, o, t, j, l, s, z = map(int, raw_input().split())

ans = o
if j % 2 == 0:
    ans += j
    j = 0
else:
    ans += j-1
    j = 1

if l % 2 == 0:
    ans += l
    l = 0
else:
    ans += l-1
    l = 1

if j == 1 and l == 1 and i > 0:
    ans += 3
    i -= 1

if i % 2 == 0:
    ans += i
else:
    ans += i-1

print ans

Submission status: Wrong Answer

Solution code:
i,o,t,j,l,s,z = map(int,input().split())

k = 0
k += (i // 2) *2
k += o
k += (j //2) *2
k += (l //2) *2
if i % 2 == 1 and j % 2 == 1 and l % 2 == 1:
	k += 1

print(k)

Submission status: Wrong Answer

Solution code:
def solve():
    ia, oa, ta, ja, la, sa, za = map(int, input().split())
    ans = 0
    object_min = min(ia, ja, la) 
    ans += object_min * 3
    ans += oa
    ans += max(0, (ia - object_min))
    ans += max(0, (min(ja, la) - object_min) * 2)
    print(ans)

if __name__=="__main__":
    solve()

Submission status: Wrong Answer

Solution code:
i, o, t, j, l, s, z = map(int, raw_input().split())

ans = o
if j % 2 == 0:
    ans += j
    j = 0
else:
    ans += j-1
    j = 1

if l % 2 == 0:
    ans += l
    l = 0
else:
    ans += l-1
    l = 1

if j == 1 and l == 1 and i > 0:
    ans += 1
    i -= 1

if i % 2 == 0:
    ans += i
else:
    ans += i-1

print ans

Submission status: Wrong Answer

Solution code:
# coding: utf-8

I, O, T, J, L, S, Z = [int(i) for i in input().split()]

K = (I//2)*2 + O + (J//2)*2 + (L//2)*2
if I % 2 == 1 and J % 2 == 1 and L % 2 ==1:
    K += 3
elif I % 2 + J % 2 + L % 2 == 2:
    K += 1
print(K)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

I, O, T, J, L, S, Z = [int(i) for i in input().split()]

K = (I//2)*2 + O + (J//2)*2 + (L//2)*2
if I % 2 == 1 and J % 2 == 1 and L % 2 ==1:
    K += 3
elif J % 2 == 1 and L % 2 == 1:
    K += 1
print(K)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
total = a[1]
i6 = max(min(a[0],a[3],a[4]) - 1, 0)
a[0] -= i6
a[3] -= i6
a[4] -= i6
if a[3]%2 == 0 and a[4]%2 == 0:
    pass
else:
    i6 += 1
    a[0] -= 1
    a[3] -= 1
    a[4] -= 1
total += i6 * 3
total += a[0] //2*2
total += a[3]//2 *2
total += a[4]//2 *2
print(total)

Submission status: Wrong Answer

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

K = 0

# square
K += a[1] * 1

mini = int(1e10)
for e in [0, 3, 4]:
	mini = min(mini, a[e])
K += mini * 3

for e in [0, 3, 4]:
	a[e] -= mini
	K += (a[e] // 2) * 2

print(K)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

I, O, T, J, L, S, Z = [int(i) for i in input().split()]

K = (I//2)*2 + O + (J//2)*2 + (L//2)*2
if I % 2 == 1 and J % 2 == 1 and L % 2 ==1:
    K += 3
print(K)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

I, O, T, J, L, S, Z = [int(i) for i in input().split()]

print((I//2)*2 + O + (J//2)*2 + (L//2)*2)

Submission status: Wrong Answer

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

K = 0

# square
K += a[1] * 1

for e in [0, 3, 4]:
	K += (a[e] // 2) * 2
	a[e] = a[e] % 2

if a[0] == 1 and a[3] == 1 and a[4] == 1:
	K += 3

print(K)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
I,O,T,J,L,S,Z = map(int,input().split())
ans = O
ans += (J // 2) * 2
ans += (L // 2) * 2
ans += (I // 2) * 2
J -= (J // 2) * 2
L -= (L // 2) * 2
I -= (I // 2) * 2
if J * L * I > 0:
    ans += 3
print(ans)

Submission status: Wrong Answer

Solution code:
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
def rl(s): return xrange(len(s))

INF = 2147483647


import sys
stdin = sys.stdin

ai, ao, at, aj, al, aS, az = map(int, stdin.readline().strip().split())


rr = ao

triples = min([ai, aj, al])
rr += 3*triples
rr += (2*((ai - triples) // 2)
      +2*((aj - triples) // 2)
      +2*((al - triples) // 2))

print rr

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    a = list(map(int, input().split()))
    t = min(a[0], a[3], a[4])
    r = t * 3
    a[0] -= t
    a[3] -= t
    a[4] -= t
    for i in [0,3,4]:
        r += a[i] // 2 * 2
    if t > 0:
        rr = (t-1) * 3
        for i in [0,3,4]:
            r += (a[i]+1) // 2 * 2
    return a[1] + r


print(main())

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, raw_input().split())
ans = 0
for i in range(2):
    ans = max(ans, (aI-i)/2*2+aO+(aJ-i)/2*2+(aL-i)/2*2+3*i)

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, raw_input().split())
ans = 0
for i in range(2):
    ans = max(ans, (aI-i)/2*2+aO+(aJ-i)/2*2+(aL-i)/2*2+3)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    a = list(map(int, input().split()))
    t = min(a[0], a[3], a[4])
    r = t * 3
    a[0] -= t
    return a[0] // 2 * 2 + a[1] + r


print(main())

Submission status: Wrong Answer

Solution code:
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
def rl(s): return xrange(len(s))

INF = 2147483647


import sys
stdin = sys.stdin

ai, ao, at, aj, al, aS, az = map(int, stdin.readline().strip().split())

print ao + 2*(ai // 2) + 2*(aj // 2) + 2*(al // 2)

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, raw_input().split())
print aI/2*2+aO+aJ/2*2+aL/2*2+(3 if aI%2>0 and aJ%2>0 and aL%2>0 else 0)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def main():
    a = list(map(int, input().split()))
    return a[0] // 2 * 2 + a[1]


print(main())

Submission status: Wrong Answer

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, raw_input().split())
print aI/2*2+aO+aJ/2*2+aL/2*2

Submission status: Time Limit Exceeded

Solution code:
aI, aO, _, aJ, aL, _, _ = map(int,input().split())

"""
aO -> +1
aI, aJ, aL -> +3
aI * 2 -> +2
aJ * 2 -> +2
aL * 2 -> +2
"""

ansK = aO
for IJL in range(min(aI,aJ,aL) + 1):
    K = aO
    K += IJL * 3
    K += ((aI - IJL) // 2) * 2
    K += ((aJ - IJL) // 2) * 2
    K += ((aL - IJL) // 2) * 2
    ansK = max(ansK, K)

print(ansK)

Submission status: Time Limit Exceeded

Solution code:
a_i,a_o,a_t,a_j,a_l,a_s,a_z=map(int,input().split())
ans1=0
ans1+=a_o
ans2=0
for i in range(min(a_i,a_j,a_l)+1):
  tmp=3*i+2*((a_i-i)//2+(a_j-i)//2+(a_l-i)//2)
  ans2=max(ans2,tmp)
print(ans1+ans2)

Submission status: Time Limit Exceeded

Solution code:
i, o, t, j, l, s, z = map(int, raw_input().split())

ans = o
while j > 0 and l > 0 and i > 0:
    j -= 1
    l -= 1
    i -= 1
    ans += 3

if j % 2 == 0:
    ans += j
    j = 0
else:
    ans += j-1
    j = 1

if l % 2 == 0:
    ans += l
    l = 0
else:
    ans += l-1
    l = 1

if i % 2 == 0:
    ans += i
else:
    ans += i-1

print ans

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
if l[0]==0 or l[3]==0 or l[4]==0:
  print((l[0]//2)*2+(l[3]//2+l[4]//2)*2+l[1])
else:
  print(max((l[0]//2)*2+(l[3]//2+l[4]//2)*2+l[1],((l[0]-1)//2)*2+((l[3]-1)//2+(l[4]-1)//2)*2+l[1]+3))

Submission status: Accepted

Solution code:
i,o,_,j,l,_,_ = map(int, input().split())

ans=i//2*2 + j//2*2 + l//2*2
jil_ok=(i>=1 and j>=1 and l>=1)
if jil_ok:
    ans=max(ans,3 + (i-1)//2*2 + (j-1)//2*2 + (l-1)//2*2)
print(ans+o)

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z=map(int,input().split())
ans1=o
ans1+=2*(i//2)
ans1+=2*(j//2)
ans1+=2*(l//2)
if i%2==j%2==l%2==1:
  ans1+=3
ans2=o
if i and j and l:
  ans2+=3
  i-=1
  l-=1
  j-=1
ans2+=2*(i//2)
ans2+=2*(l//2)
ans2+=2*(j//2)
print(max(ans1,ans2))

Submission status: Accepted

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

ans = 2*(a[0]//2 + a[3]//2 + a[4]//2) + 3*(1 & a[0] & a[3] & a[4])
if a[0] and a[3] and a[4]:
    ans = max(ans, 2*((a[0]-1)//2 + (a[3]-1)//2 + (a[4]-1)//2) + 3)

print(int(ans + a[1]))

Submission status: Accepted

Solution code:
I, O, T, J, L, S, Z = map(int,input().split())
ans = (I // 2) * 2 + (J // 2) * 2 + (L // 2) * 2 + O
if I > 0 and J > 0 and L > 0:
    ans = max(ans, ((I - 1) // 2) * 2 + ((J - 1) // 2) * 2 + ((L - 1) // 2) * 2 + O + 3)
print(ans)

Submission status: Accepted

Solution code:
ai,ao,at,aj,al,As,az = map(int,input().split())

ans = (ai//2)*4 + ao*2 + (aj//2)*4 + (al//2)*4
if(ai>0)&(aj>0)&(al>0):
    ai -= 1
    aj -= 1
    al -= 1
    tmp = 6 + (ai//2)*4 + ao*2 + (aj//2)*4 + (al//2)*4
    ans = max(ans,tmp)
print(ans//2)

Submission status: Accepted

Solution code:
ni,no,nt,nj,nl,ns,nz=map(int,input().split())
ans=0
ans+=no
c=0
c+=ni%2
c+=nl%2
c+=nj%2
# c:奇数の個数
if c==3 or c==0:
  ans+=ni+nj+nl
elif c==1:
  ans+=ni+nj+nl-1
elif ni>0 and nj>0 and nl>0:
  ans+=ni+nj+nl-1
else:
  ans+=ni+nj+nl-2
print(ans)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
res = 0
if A[0]%2 + A[3]%2 + A[4]%2 >=2 and A[0]*A[3]*A[4]>0:
    A[0] -= 1
    A[3] -= 1
    A[4] -= 1
    res += 3
res += A[0]//2*2
res += A[1]
res += A[4]//2*2
res += A[3]//2*2
print(res)

Submission status: Accepted

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

res = A[1]

p = A[0],A[3],A[4]

res += max(sum(v//2 for v in p)*2,
    sum((v-1)//2 for v in p)*2+3 if all(v>0 for v in p) else 0)

print(res)

Submission status: Accepted

Solution code:
I, O, T, J, L, S, Z = map(int, input().split())

width = 0


if L % 2 + J % 2 + I % 2 >= 2 and L*J*I > 0:
    width += 6
    L -= 1
    J -= 1
    I -= 1

width += O * 2

width += I // 2 * 4
I %= 2

width += L // 2 * 4
L %= 2

width += J // 2 * 4
J %= 2


print(width // 2)

Submission status: Accepted

Solution code:
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    a,b,c,d,e,f,g = map(int,ipt().split())
    ans = (a//2*2+b+d//2*2+e//2*2)
    if a*d*e%2:
        ans += 3
    elif (d*e%2 and a != 0) or (a*d%2 and e != 0) or (a*e%2 and d != 0):
        ans += 1
    print(ans)

    return None

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    I, O, T, J, L, S, Z = map(int, input().split())
    ans = O
    if L >= 1 and J >= 1 and I >= 1 and (J % 2) + (L % 2) + (I % 2) >= 2:
        J -= 1
        L -= 1
        I -= 1
        ans += 3
    ans += I // 2 * 2
    ans += J // 2 * 2
    ans += L // 2 * 2
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
ai,ao,at,aj,al,aS,az=map(int,input().split())
ans = ao
if aj > 0 and al > 0 and ai > 0:
    print(ao + max(2 * (ai // 2 + al // 2 + aj // 2), 3 + 2 * ((ai - 1) // 2 + (al - 1) // 2 + (aj - 1) // 2)))
else:
    print(ao + 2 * (ai // 2 + al // 2 + aj // 2))

Submission status: Accepted

Solution code:
i, o, t, j, l, s, z = map(int, input().split())
ans = o + (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
if l * i * j != 0:
    l -= 1
    i -= 1
    j -= 1
    ans2 = o + (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2 + 3
    ans = max(ans, ans2)
print(ans)

Submission status: Accepted

Solution code:
I,O,T,J,L,S,Z=map(int,input().split())
print(max((~-I//2+~-J//2+~-L//2)*2+3*(I>0<L>0<J),I//2+J//2+L//2<<1)+O)

Submission status: Accepted

Solution code:
I,O,T,J,L,S,Z=map(int,input().split())
print(max((~-I//2+~-J//2+~-L//2)*2+O+3*(I>0<L>0<J),(I//2+J//2+L//2)*2+O))

Submission status: Accepted

Solution code:
I, O, T, J, L, S, Z = map(int, input().split())
length = O*2 + (I//2)*4 + (J//2)*4 + (L//2)*4
if I and J and L:
  length = max(length, 6 + O*2 + ((I-1)//2)*4 + ((J-1)//2)*4 + ((L-1)//2)*4)
print(length//2)

Submission status: Accepted

Solution code:
def main():
    I, O, T, J, L, S, Z = map(int, input().split())

    ans = 0
    for ijl in range(2):
        i = I - ijl
        j = J - ijl
        l = L - ijl

        if i < 0 or j < 0 or l < 0:
            continue

        cnt = 3 * ijl + (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2

        ans = max(ans, cnt)

    ans += O
    print(ans)


if __name__ == '__main__':
    main()

"""
II
IJL
O
JJ
LL

IJLの使用回数(偶数または奇数の2通り)それぞれで
II/JJ/LL/Oで使用する個数を求める
"""

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

I, O, T, J, L, S, Z = mapint()

if I==0 or J==0 or L==0:
    three = 0
elif I%2+J%2+L%2>=2:
    three = 1
    I -= 1
    J -= 1
    L -= 1
else:
    three = 0

ans = O+(I//2+J//2+L//2)*2+three*3
print(ans)

Submission status: Accepted

Solution code:
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())

K = aO + aI // 2 * 2 + aJ // 2 * 2 + aL // 2 * 2

if aI > 0 and aJ > 0 and aL > 0:
  K = max(aO + 3 + (aI - 1) // 2 * 2 + (aJ - 1) // 2 * 2 + (aL - 1) // 2 * 2, K)

print(K)

Submission status: Accepted

Solution code:
A=list(map(int,input().split()))
print(A[1]+(A[0]//2+A[3]//2+A[4]//2)*2 if 0 in (A[0],A[3],A[4]) or A[0]%2+A[3]%2+A[4]%2<2 else A[1]+((A[0]-1)//2+(A[3]-1)//2+(A[4]-1)//2)*2+3)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

I, O, T, J, L, S, Z = map(int, read().split())

x = O
y = 3 + 2 * ((L - 1) // 2 + (I - 1) // 2 + (J - 1) // 2)  # LIJ あり
if L == 0 or I == 0 or J == 0:
    y = 0
z = 2 * (L // 2 + I // 2 + J // 2)  # LIJ なし
x += max(y, z)
print(x)

Submission status: Accepted

Solution code:
aI, aO, _, aJ, aL, _, _ = map(int, input().split())


def f(i, j, l):
    return aO + 2 * (i // 2 + j // 2 + l // 2)


ans = f(aI, aJ, aL)
if aI and aJ and aL:
    ans = max(ans, 3 + f(aI - 1, aJ - 1, aL - 1))
print(ans)

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z = map(int,input().split())
if i > 0 and j > 0 and l > 0:
  print(max(o + i//2*2 + j//2*2 + l//2*2,o + (i-1)//2*2 + (j-1)//2*2 + (l-1)//2*2 + 3))
else:
  print(o + i//2*2 + j//2*2 + l//2*2)

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z=map(int,input().split())
ans=o
ans+=i-(i%2)
ans+=l-(l%2)
ans+=j-(j%2)
if i%2+j%2+l%2==3:
  ans+=3
elif i%2+j%2+l%2==2:
  if i*j*l>0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


i, o, t, j, l, s, z = map(int, input().split())
ans = 0
ans += o

def sub(i,j,l):
    best = 0
    if j>=1 and l>=1 and i>=1:
        v = (i if i%2 else i-1) + (j-1)//2*2 + (l-1)//2*2 + 2
        best = max(v, best)
    v = (i if i%2==0 else i-1) + (j//2)*2 + (l//2)*2
    best = max(v, best)
    return best
ans += sub(i,j,l)
print(ans)

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
ans = a[1]
c = a[0]%2+a[3]%2+a[4]%2
if c == 3:
  ans += a[0]+a[3]+a[4]
elif c == 2 and a[0]*a[3]*a[4] != 0:
  ans += a[0]+a[3]+a[4]-1
else:
  ans += a[0]//2*2+a[3]//2*2+a[4]//2*2
print(ans)

Submission status: Accepted

Solution code:
i, o, _, j, l, _, _ = map(int, input().split())
if i >= 1 and j >= 1 and l >= 1:
    print((max(6 + ((i - 1) // 2 + (j - 1) // 2 + (l - 1) // 2) * 4, (i // 2 + j // 2 + l // 2) * 4) + 2 * o) // 2)
else:
    print((((i // 2 + j // 2 + l // 2) * 4) + 2 * o) // 2)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

ai, ao, _, aj, al, _, _ = map(int, input().split())
ans = ao+ai//2*2+aj//2*2+al//2*2

if ai>=1 and aj>=1 and al>=1:
    ans_ = ao+(ai-1)//2*2+3
    ans_ += (aj-1)//2*2+(al-1)//2*2
    ans = max(ans, ans_)

print(ans)

Submission status: Accepted

Solution code:
i, o, t, j, l, s, z = map(int, input().split())

k = 0
k += (i // 2) * 2
k += o
k += (j // 2) * 2
k += (l // 2) * 2
if i%2 == 1 and j%2 == 1 and l%2 == 1:
    k += 3

kk = 0
if i >= 1 and j >= 1 and l >= 1:
    kk += 3
    i -= 1
    j -= 1
    l -= 1
kk += (i // 2) * 2
kk += o
kk += (j // 2) * 2
kk += (l // 2) * 2

print(max(k, kk))

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    I, O, T, J, L, S, Z = map(int, input().split())
    Ans = O
    six = min([I, J, L])
    Ans += 3 * six
    I -= six
    J -= six
    L -= six
    Ans += 2 * (I // 2 + J // 2 + L // 2)
    rem = I % 2 + J % 2 + L % 2
    if six > 0 and rem == 2: Ans += 1
    print(Ans)
    
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
I, O, _, J, L, _, _ = map(int, input().split())

ans = O * 2

if sum([a % 2 for a in (I, J, L)]) >= 2 and min(I, J, L) >= 1:
    I -= 1
    J -= 1
    L -= 1
    ans += 6

ans += sum([(a // 2) * 4 for a in (I, J, L)])
print(ans // 2)

Submission status: Accepted

Solution code:
I, O, T, J, L, S, Z = map(int, input().split())
ans = O
d = min(I, J, L)
a1 = 3 * d + (I - d) // 2 * 2 + (J - d) // 2 * 2 + (L - d) // 2 * 2
d -= 1
a2 = 0
if d >= 0:
    a2 = 3 * d + (I - d) // 2 * 2 + (J - d) // 2 * 2 + (L - d) // 2 * 2
ans += max(a1, a2)
print(ans)

Submission status: Accepted

Solution code:
aI, aO, _, aJ, aL, _, _ = map(int, input().split())

ans = 0

# JILを作る
if aI * aJ * aL > 0:
    tmp = 3
    tmp += 2 * ((aI - 1) // 2)
    tmp += 2 * ((aL - 1) // 2)
    tmp += 2 * ((aJ - 1) // 2)
    tmp += aO
    ans = max(ans, tmp)

# JILを作らない
tmp = 0
tmp += 2 * (aI // 2)
tmp += 2 * (aL // 2)
tmp += 2 * (aJ // 2)
tmp += aO
ans = max(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
a,b,c,d,e,f,g=map(int,input().split())
check=[a%2,d%2,e%2]
if check.count(1)==3 or check.count(1)==0:
    print(a+b+d+e)
elif check.count(1)==1:
    print(a+b+d+e-1)
else:
    if a*d*e>0:
        print(a+b+d+e-1)
    else:
        print(a+b+d+e-2)

Submission status: Accepted

Solution code:
a,b,_,c,d,_,_=map(int,input().split())
e=0
if a%2+c%2+d%2>=2 and a>0 and c>0 and d>0:
    e=3
    a-=1
    c-=1
    d-=1
print((a//2)*2+b+(c//2)*2+(d//2)*2+e)

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z=map(int,input().split())
ans=0
ans+=o
if j==1 and l==1 and i==1:
    ans+=3
elif j<2 and l<2 and i<2:
    ans+=0
elif j%2==1 and l%2==1 and i%2==1:
    ans+=j+i+l
elif j%2==1 and l%2==1 and i%2==0:
    ans+=j+i+l-1
elif j%2==1 and l%2==0 and i%2==1:
    ans+=j+i+l-1
elif j%2==1 and l%2==0 and i%2==0:
    ans+=j+i+l-1
elif j%2==0 and l%2==1 and i%2==1:
    ans+=j+i+l-1
elif j%2==0 and l%2==1 and i%2==0:
    ans+=j+i+l-1
elif j%2==0 and l%2==0 and i%2==1:
    ans+=j+i+l-1
elif j%2==0 and l%2==0 and i%2==0:
    ans+=j+i+l
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# T,S,Zは使えない
# I,J,Lを1つずつ使うと偶奇の調整ができる

A = LI()
d = defaultdict()
name = ['I','O','T','J','L','S','Z']
for i,a in enumerate(A):
    d[name[i]] = a

ans = d['O']

use = ['I','J','L']
odd = []
even = []
for k in use:
    if d[k]%2:
        odd.append(k)
    else:
        even.append(k)

if len(odd) == 3:
    ans += 3
    for k in use:
        ans += ((d[k]-1)//2)*2
elif len(odd) == 2:
    if d[even[0]] > 0:
        ans += 3
        for k in use:
            ans += ((d[k]-1)//2)*2
    else:
        for k in use:
            ans += (d[k]//2)*2
elif len(odd) == 1:
    for k in use:
        ans += (d[k]//2)*2
else:
    for k in use:
        ans += (d[k]//2)*2

print(ans)

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z=[int(i) for i in input().split()]

ans=o*2+4*(i//2)+4*(l//2)+4*(j//2)
if i*l*j>0:ans=max(ans,o*2+4*((~-i)//2)+4*((~-l)//2)+4*((~-j)//2)+6)

print(ans//2)

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z=map(int,input().split())
ansl=[o,o]
ansl[0]+=3+(max(0,(i-1)//2))*2+(max(0,(j-1)//2))*2+(max(0,(l-1)//2))*2
ansl[1]+=(i//2)*2+(j//2)*2+(l//2)*2
if i>=1 and j>=1 and l>=1:
    print(max(ansl))
else:
    print(ansl[1])

Submission status: Accepted

Solution code:
a,b,q,c,d,w,f=map(int,input().split())
k=[b,b]
k[0]+=(a-(a%2)+c-(c%2)+d-(d%2))
if a%2==1 and c%2==1 and d%2==1:
  k[0]+=3
if a and c and d:
  a-=1;c-=1;d-=1
  k[1]+=(3+a-(a%2)+c-(c%2)+d-(d%2))
print(max(k))

Submission status: Accepted

Solution code:
## coding: UTF-8
#最後の方のテストケースでREになってしまう。時間切れ。
#from decimal import *
#from itertools import permutations, combinations,combinations_with_replacement,product

#N = int(input())

s = input().split()
p = [int(w) for w in s]

#print(p)

I = p[0]
O = p[1]
#T = p[2] #使わない
J = p[3]
L = p[4] 
#S = p[5] #使わない
#Z = p[6] #使わない

answer = 0

answer += O #O型は最初に全部使います。


if(I % 2 == J % 2 and I % 2 == L % 2):
    #[odd,odd,odd] or [even,even,even]
    #[0,0,0],[0,0,even],[0,even,even]
    answer += I+J+L
elif( (I + J + L) % 2 == 1):
    #[even,even,odd]
    #[0,0,odd],[0,even,odd]
    answer += I+J+L-1
elif( (I == 0 and J % 2 == 1 and L % 2 == 1)  or (J == 0 and I % 2 == 1 and L % 2 == 1)  or  (L == 0 and J % 2 == 1 and I % 2 == 1)  ):
    answer += I+J+L-2
else:
    #[even,odd,odd]
    #if(min(I,J,L) % 2 == 0):
        #answer += I+J+L - 2
    #else:
        #answer += I+J+L - 1
    answer += I+J+L-1

print(answer)

Submission status: Accepted

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

cnt = (a[0] // 2) * 4
cnt += a[1] * 2
cnt += (a[3] // 2) * 4
cnt += (a[4] // 2) * 4

IJL = (a[0] % 2 + a[3] % 2 + a[4] % 2)
if IJL == 2 and bool(a[0]) + bool(a[3]) + bool(a[4]) >= 3:
    cnt += 2
elif IJL == 3:
    cnt += 6

print(cnt // 2)

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z = map(int, input().split())
k = o
p = (i//2 + j//2 + l//2)*2
q = 0
if i*j*l:
  q = ((i-1)//2 + (j-1)//2 + (l-1)//2)*2 + 3
print(k + max(p, q))

Submission status: Accepted

Solution code:
aI, aO, _, aJ, aL, _, _ = map(int, input().split())
ans = aI//2*2+aO+aJ//2*2+aL//2*2

if min(aI, aJ, aL)>=1:
    ans = max(ans, 3+(aI-1)//2*2+aO+(aJ-1)//2*2+(aL-1)//2*2)

print(ans)

Submission status: Accepted

Solution code:
#c
#ignore t,s,z
a = [int(i) for i in input().split()]
ans = a[1]
b = [a[0],a[3],a[4]] #select

for i,v in enumerate(b):
    if v>2:
        if v%2==1: #odd
            ans += v-1
            b[i] = 1
        else:
            ans += v-2
            b[i] = 2

s = sum(b)
if s==6:
    ans += 6
elif s==5:
    ans += 4
elif s==4:
    if min(b)==0:
        ans += 4
    else:
        ans += 3
elif s==3:
    if max(b)==2:
        ans += 2
    else:
        ans += 3
elif s==2:
    if max(b)==2:
        ans += 2

print(ans)

Submission status: Accepted

Solution code:
import sys
def main():
    input = sys.stdin.readline
    i,o,t,j,l,s,z = map(int, input().split())

    ans1 = o
    ans1 += i&(~1)
    ans1 += j&(~1)
    ans1 += l&(~1)

    ans2 = o
    if i and j and l:
        ans2 += 3
        ans2 += (i-1)&(~1)
        ans2 += (j-1)&(~1)
        ans2 += (l-1)&(~1)

    print(max(ans1, ans2))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
I,O,_,J,L,_,_ = map(int,input().split())
ans1 = O + I-I%2 + J-J%2 + L-L%2
ans2 = 0
if I and J and L:
    I,J,L = I-1,J-1,L-1
    ans2 = 3 + O + I-I%2 + J-J%2 + L-L%2
print(max(ans1,ans2))

Submission status: Accepted

Solution code:
I, O, T, J, L, S, Z = map(int, input().split())
k0 = 0
k0 += (I//2)*2
k0 += (J//2)*2
k0 += (L//2)*2

k1 = 0
if I >= 1 and J >= 1 and L >= 1:
    k1 = 0
    k1 += 3
    I -= 1
    J -= 1
    L -= 1
    k1 += (I//2)*2
    k1 += (J//2)*2
    k1 += (L//2)*2

k = max(k0, k1)
k += O
print(k)

Submission status: Accepted

Solution code:
I, O, T, J, L, S, Z = map(int, input().split())
ans = 0

ans += O * 2

if sum([i % 2 for i in [I, J, L]]) >= 2:
    mi = min(I, J, L, 1)
    ans += mi * 6
    I -= mi
    J -= mi
    L -= mi

ans += (I // 2) * 4
ans += (J // 2) * 4
ans += (L // 2) * 4

print(ans // 2)

Submission status: Accepted

Solution code:
aI,aO,_,aJ,aL,_,_ = map(int, input().split())

ans1 = (aI // 2 + aJ // 2 + aL // 2) * 2
if min(aI, aJ, aL) > 0:
    ans2 = 3 + ((aI-1) // 2 + (aJ-1) // 2 + (aL-1) // 2) * 2
else:
    ans2 = 0

print(max(ans1, ans2) + aO)

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    I, O, T, J, L, S, Z = map(int, input().split())
    #I * 2: 4; O * 1: 2, J, L * 2: 4, I + J + L: 6 
    Ans = O * 2
    six = min([I, J, L])
    Ans += six * 6
    I -= six
    J -= six
    L -= six
    Ans += 4 * (I // 2 + J // 2 + L // 2)
    rem = I % 2 + J % 2 + L % 2
    if six > 0 and rem == 2: Ans += 2
    print(Ans // 2)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z=map(int, input().split())
ans=o+j//2*2+l//2*2+i//2*2+(i&1 and j&1 and l&1)*3
k=min(i,j,l)
for n in range(max(0,k-10),k+1):
    ans=max(ans,o+n*3+(i-n)//2*2+(j-n)//2*2+(l-n)//2*2)
print(ans)

Submission status: Accepted

Solution code:
aI, aO, _, aJ, aL, _, _ = map(int,input().split())

"""
aO -> +1
aI, aJ, aL -> +3
aI * 2 -> +2
aJ * 2 -> +2
aL * 2 -> +2

aI, aJ, aLを2個作ると、
aI * 2, aJ * 2, aL * 2に分解できる
"""

# aI, aJ, aLを0個作る
ans0 = aO + (aI // 2 + aJ // 2 + aL // 2) * 2
# aI, aJ, aLを1個作る
if min(aI, aJ, aL) > 0:
    ans1 = aO + 3 + ((aI-1) // 2 + (aJ-1) // 2 + (aL-1) // 2) * 2
else:
    ans1 = 0
print(max(ans0, ans1))

Submission status: Accepted

Solution code:
import sys

def solve():
    i, o, t, j, l, s, z = map(int, input().split())
    length = o * 2
    #長方形>> i2個, l2個, j2個: length += 4; i, l, j1個ずつ: length += 6
    comb = min([i, j, l])
    length += 6 * comb
    i -= comb
    j -= comb
    l -= comb
    length += 4 * ((i // 2) + (j // 2) + (l // 2))
    lem = i % 2 + j % 2 + l % 2
    if lem == 2 and comb > 0: length += 2
    elif lem == 3 and comb > 0: length += 6
    print(length // 2)
   
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
i,o,t,j,l,s,z = map(int,input().split())
ans1 = o + ((i-1)//2)*2 + ((j-1)//2)*2 + ((l-1)//2)*2
if i*j*l >= 1:
    ans1 += 3
ans2 = o + (i//2)*2 + (j//2)*2 + (l//2)*2
ans = max(ans1,ans2)
print(ans)

Submission status: Accepted

Solution code:
a, b, _, c, d, _, _ = map(int, input().split())

print(a//2*2 + (1 if a>0 and b>0 and c>0 and a%2 + c%2 + d%2 == 2 else 0) + (3 if a%2 + c%2 + d%2 == 3 else 0) +b+c//2*2+d//2*2)