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.

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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]))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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

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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
'''
研究室PCでの解答
'''
import math

import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 
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()

Solution (Python):
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()

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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で使用する個数を求める
"""

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)  
if L == 0 or I == 0 or J == 0:
    y = 0
z = 2 * (L // 2 + I // 2 + J // 2)  
x += max(y, z)
print(x)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
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)

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

ans = 0


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)


tmp = 0
tmp += 2 * (aI // 2)
tmp += 2 * (aL // 2)
tmp += 2 * (aJ // 2)
tmp += aO
ans = max(ans, tmp)

print(ans)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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))






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)

Solution (Python):
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)

Solution (Python):
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])

Solution (Python):
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))

Solution (Python):







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



I = p[0]
O = p[1]

J = p[3]
L = p[4] 



answer = 0

answer += O 


if(I % 2 == J % 2 and I % 2 == L % 2):
    
    
    answer += I+J+L
elif( (I + J + L) % 2 == 1):
    
    
    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:
    
    
        
    
        
    answer += I+J+L-1

print(answer)

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):


a = [int(i) for i in input().split()]
ans = a[1]
b = [a[0],a[3],a[4]] 

for i,v in enumerate(b):
    if v>2:
        if v%2==1: 
            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)

Solution (Python):
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()

Solution (Python):
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))

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    I, O, T, J, L, S, Z = map(int, input().split())
    
    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()

Solution (Python):
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)

Solution (Python):
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に分解できる
"""


ans0 = aO + (aI // 2 + aJ // 2 + aL // 2) * 2

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))

Solution (Python):
import sys

def solve():
    i, o, t, j, l, s, z = map(int, input().split())
    length = o * 2
    
    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()

Solution (Python):
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)

Solution (Python):
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)

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

Solution (Python):
import sys
input = sys.stdin.readline
I, O, _, J, L, _, _ = map(int, input().split())
m = min(I, J, L)
res = m * 3 + ((I - m) // 2) * 2 + ((J - m) // 2) * 2 + ((L - m) // 2) * 2 + O
m -= 1
if m < 0: m = 0
res = max(res, m * 3 + ((I - m) // 2) * 2 + ((J - m) // 2) * 2 + ((L - m) // 2) * 2 + O)
print(res)

Solution (Python):
I, O, T, J, L, S, Z = map(int, raw_input().strip().split())

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

if (I % 2 == 1) and (J % 2 == 1) and (L % 2 == 1):
  ans += 3
elif (I % 2 == 1) and (J % 2 == 1) and L > 0:
  ans += 1
elif (I % 2 == 1) and (L % 2 == 1) and J > 0:
  ans += 1
elif (J % 2 == 1) and (L % 2 == 1) and I > 0:
  ans += 1

print ans

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

Solution (Python):
i, o, t, j, l, s, z = map(int, input().split())
if i < 1 or j < 1 or l < 1:
    ans1 = 0
else:
    ans1 = ((i - 1) // 2 + (l - 1) // 2 + (j - 1) // 2) * 2 + 3
ans2 = (i // 2 + j // 2 + l // 2) * 2
print(max(ans1, ans2) + o)

Solution (Python):
a,x,nn,b,c,nnn,nnnn=map(int,input().split())
ans=x+a//2*2+b//2*2+c//2*2
if a*b*c:
  j=a%2+b%2+c%2
  if j==2:
    ans+=1
  if j==3:
    ans+=3
print(ans)

Solution (Python):
A = list(map(int, input().split()))
S = A[1]
S += (A[0] // 2) * 2 + (A[3] // 2) * 2 + (A[4] // 2) * 2
if A[3] % 2 == 1 and A[4] % 2 == 1 and A[0] % 2 == 1:
  S += 3
elif A[3] % 2 == 1 and A[4] % 2 == 1 and A[0] % 2 == 0 and A[0] != 0:
  S += 1
elif A[3] % 2 == 0 and A[4] % 2 == 1 and A[0] % 2 == 1 and A[3] != 0:
  S += 1
elif A[3] % 2 == 1 and A[4] % 2 == 0 and A[0] % 2 == 1 and A[4] != 0:
  S += 1
print(S)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check1(I, J, L):
    res = 0
    res += I - I%2
    res += J - J%2
    res += L - L%2
    return res

def check2(I, J, L):
    res = 0
    if I > 0 and J > 0 and L > 0:
        res += 3
        I -= 1
        J -= 1
        L -= 1
    res += I - I%2
    res += J - J%2
    res += L - L%2
    return res

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

ans = O
ans += max(check1(I, J, L), check2(I, J, L))
print(ans)

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

Solution (Python):

import sys
INF = float("inf")


def solve(a_I: int,
          a_O: int,
          a_T: int,
          a_J: int,
          a_L: int,
          a_S: int,
          a_Z: int):

    
    ans = a_O

    
    A = 2*(a_I//2) + 2*(a_J//2) + 2*(a_L//2)
    if a_I > 0 and a_J > 0 and a_L > 0:
        B = 3+2*((a_I-1)//2) + 2*((a_J-1)//2) + 2*((a_L-1)//2)
    else:
        B = 0
    ans += max(A, B)

    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a_I = int(next(tokens))  
    a_O = int(next(tokens))  
    a_T = int(next(tokens))  
    a_J = int(next(tokens))  
    a_L = int(next(tokens))  
    a_S = int(next(tokens))  
    a_Z = int(next(tokens))  
    solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z)


if __name__ == '__main__':
    main()

Solution (Python):

ai,ao,at,aj,al,ass,az = map(int,input().split())

ans = ao

if ai * aj * al > 0:
    if ai%2+aj%2+al%2 in [0,3]:
        ans += ai + aj + al
    else:
        ans += ai + aj + al - 1

else:
    ans += ai//2*2 + aj//2*2 + al//2*2

print (ans)

Solution (Python):
I,O,T,J,L,S,Z=map(int,input().split())
i=I%2
j=J%2
l=L%2
if i+j+l>=2:
  if i+j+l==3:
    print(I+O+J+L)
  elif I*J*L!=0:
    print((I-1)//2*2+O+(J-1)//2*2+(L-1)//2*2+3)
  else:
    print(I//2*2+O+J//2*2+L//2*2)
else:
  print(I//2*2+O+J//2*2+L//2*2)

Solution (Python):
I,O,R,J,L,S,Z=map(int,input().split())
a=(I//2+J//2+L//2)*2
b=0
if I*J*L!=0:b=(2*((I-1)//2+(J-1)//2+(L-1)//2)+3)
print(max(a,b)+O)

Solution (Python):
def examA():
    x, y = LI()
    ans = 0
    if x<0 and y<0:
        if x<=y:
            ans = y-x
        else:
            ans = x-y+2
    elif x<0 and 0<=y:
        if -x<=y:
            ans = y+x+1
        else:
            ans = min(-(x+y)+1,y-x)
    elif y<=0:
        ans = abs(y+x)+1
    else:
        if x<=y:
            ans = y-x
        else:
            ans = x-y+2
    print(ans)
    return

def examB():
    B, K = LI()
    A = LI()
    cumA = [0]*(B+1); negA = [0]*(B+1)
    for i,a in enumerate(A):
        cumA[i+1] = cumA[i]
        negA[i+1] = negA[i]
        if a>0:
            cumA[i+1] +=a
        else:
            negA[i+1] +=a
    ans = 0
    for i in range(B-K+1):
        curC = cumA[K+i]-cumA[i]; curN = negA[K+i]-negA[i]
        now1 = cumA[B] + curN
        now2 = cumA[B] - curC

        ans = max(ans,now1,now2)
    print(ans)
    return

def examC():
    Ai,Ao,At,Aj,Al,As,Az = LI()
    ans = 0
    ans += Ao
    ans += (Ai//2 + Aj//2 + Al//2)*2
    if Ai>=1 and Aj>=1 and Al>=1:
        if Ai%2 + Aj%2 + Al%2==3:
            ans += 3
        elif Ai%2 + Aj%2 + Al%2==2:
            ans +=1
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18

if __name__ == '__main__':
    examC()

Solution (Python):
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())

del T,S,Z

x = O





y = ((J//2) + (I//2) + (L//2)) * 2

z = 3; J -= 1; I -= 1; L -= 1
if J < 0 or I < 0 or L < 0:
    z = -10 ** 18
z += ((J//2) + (I//2) + (L//2)) * 2
answer = x + max(y,z)
print(answer)

Solution (Python):
*A, = map(int, input().split())

d = {c: A[i] for i, c in enumerate('IOTJLSZ')}










def max_pick(x):
    return x - x % 2


ret = 0
if d['I'] and d['J'] and d['L']:
    ret = max(ret, d['O'] + max_pick(d['I'] - 1) + max_pick(d['J'] - 1) + max_pick(d['L'] - 1) + 3)
ret = max(ret, d['O'] + max_pick(d['I']) + max_pick(d['J']) + max_pick(d['L']))
print(ret)

Solution (Python):
def main():
    i, o, t, j, l, s, z = map(int, input().split())
    x = [i % 2, j % 2, l % 2]
    if x.count(1) in [0, 3]:
        ans = i+j+l+o
    else:
        if min([i, j, l]) == 0:
            ans = 2*(i//2+j//2+l//2)+o
        else:
            ans = i+j+l+o-1
    print(ans)


main()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    aI,aO,aT,aJ,aL,aS,aZ=map(int,input().split())
    ans=aO

    if(aI>=1 and aJ>=1 and aL>=1 and (aI%2+aJ%2+aL%2)==2):
        ans+=3
        aI-=1; aJ-=1; aL-=1

    ans+=(aI//2)*2
    ans+=(aJ//2)*2
    ans+=(aL//2)*2
    if(aI&1 and aJ&1 and aL&1):
        ans+=3

    print(ans)
resolve()

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

IJL = (I, J, L)

A = sum((e // 2) * 2 for e in IJL)
B = 0 if any(e <= 0 for e in IJL) else sum(((e - 1) // 2) * 2 for e in IJL) + 3

print(max(A, B) + O)

Solution (Python):
from fractions import gcd

from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7



def main():
    i, o, t, j, l, s, z = map(int, input().split())
    ans = o
    ans += (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
    

      

    ans2 = o
    mi = min(i, min(l, j))
    if mi > 0:
        mi = 1
    else:
        print(ans)
        exit()
    ans2 += mi * 3
    ans2 += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    ans = max(ans, ans2)

    print(ans)



    


    


if __name__ == '__main__':
    main()

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


I, O, _, J, L, *_ = list(map(int, sys.stdin.buffer.readline().split()))
ans = 0

ans += O



if min(I, J, L) > 0:
    s = min(I, J, L)
    I -= s
    J -= s
    L -= s
    if I % 2 + J % 2 + L % 2 == 2:
        
        s -= 1
        I += 1
        J += 1
        L += 1
    ans += s * 3
ans += (I // 2 + J // 2 + L // 2) * 2
print(ans)

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

ans = A[1]
B = [A[0], A[3], A[4]]
C = []
for b in B:
    if b == 0:
        C.append(0)
        continue
    a = (b-1)//2
    ans += a*2
    C.append(b-a*2)

if C.count(2) >= 2:
    for c in C:
        ans += c//2*2
elif min(C) == 1:
    ans += 3
else:
    for c in C:
        ans += c//2*2

print(ans)

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

def calc(I, J, L) :        
    I -= I % 2
    J -= J % 2
    L -= L % 2
    return I + J + L
    
ret = aO + calc(aI, aJ, aL)
if aI >= 1 and aJ >= 1 and aL >= 1 :
    ret = max(ret, aO + calc(aI-1, aJ-1, aL-1) + 3)

print(ret)

Solution (Python):
ai,ao,_,aj,al,_,_ = map(int,input().split())
K = 0
K += ao + (ai//2)*2 + (aj//2)*2 + (al//2)*2
if ai%2 + aj%2 + al%2 == 2 and ai > 0 and al > 0 and aj > 0:
    K += 1
if ai%2 + aj%2 + al%2 == 3:
    K += 3 
print(K)

Solution (Python):
ai, ao, at, aj, al, a_s, a_z = map(int, input().split())

b = min(ai, aj, al)
ans1 = ao + min(1, b)*3 + ((ai - min(1, b)) // 2) * 2 + ((aj - min(1, b)) // 2) * 2 + ((al - min(1, b)) // 2) * 2
ans2 = ao + (ai // 2) * 2 + (aj // 2) * 2 + (al // 2) * 2

ans = max(ans1, ans2)

print(ans)

Solution (Python):
I,O,T,J,L,S,Z=map(int,input().split())
AI=(I//2)*4
AO=O*2
AJ=(J//2)*4
AL=(L//2)*4
OI=I%2
OJ=J%2
OL=L%2
if min(I,J,L)==0:
    print((AI+AO+AJ+AL)//2)
elif (OI+OJ+OL)==3:
    print((AI+AO+AJ+AL)//2+3)
elif (OI+OJ+OL)<=1:
    print((AI+AO+AJ+AL)//2)
else:
    print((AI+AO+AJ+AL)//2+1)

Solution (Python):
AI, AO, _, AJ, AL, _, _ = map(int, input().split())

odd = AI % 2 + AJ % 2 + AL % 2
if odd == 0 or odd == 3:
    print(AI + AO + AJ + AL)
elif odd == 1:
    print(AI + AO + AJ + AL - 1)
else:
    if AI + AJ + AL == 2:
        print(AO)
    else:
        print(AI + AO + AJ + AL - 1)

Solution (Python):
I, O, _, R, L, _, _ = map(int, input().split())

ans = O
if I * R * L == 0:
    ans += (I // 2 + L // 2 + R // 2) * 2
else:
    M = I % 2 + L % 2 + R % 2
    if M <= 1:
        ans += (I // 2 + L // 2 + R // 2) * 2
    else:
        ans += 3
        I -= 1
        L -= 1
        R -= 1
        ans += (I // 2 + L // 2 + R // 2) * 2

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    a = list(map(int,input().split()))
    if a[0]*a[3]*a[4] == 0:
        ans = 2*(a[0]//2+a[3]//2+a[4]//2)
    else:
        ans = max(2*(a[0]//2+a[3]//2+a[4]//2),\
            3+2*((a[0]-1)//2+(a[3]-1)//2+(a[4]-1)//2))
    print(a[1]+ans)

if __name__ == "__main__":
    main()

Solution (Python):
a1, a2, _, a3, a4, _, _ = map(int, input().split())

ans = 0


ans += a2 * 2
a2 = 0



cnt = 0
if a1 % 2 == 0:
    cnt += 1
if a3 % 2 == 0:
    cnt += 1
if a4 % 2 == 0:
    cnt += 1
if cnt == 1 and a1 * a3 * a4 != 0:
    ans += 6
    a1 -= 1
    a3 -= 1
    a4 -= 1



ans += (a1 // 2) * 4
a1 = a1 % 2

ans += (a3 // 2) * 4
a3 = a3 % 2

ans += (a4 // 2) * 4
a4 = a4 % 2

if a1 == 1 and a3 == 1 and a4 == 1:
    ans += 6

print(ans // 2)

Solution (Python):
data = list(map(int,input().split()))
ans = data[1]
a1 = (data[0]//2)*2 + (data[3]//2)*2 + (data[4]//2)*2
a2 = 3 + ((data[0]-1)//2)*2 + ((data[3]-1)//2)*2 + ((data[4]-1)//2)*2
if data[0]*data[3]*data[4] == 0:
    a2 = 0
print(ans + max(a1,a2))