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

a = [int(item) for item in input().split()]
ans = a[1]


pata = 0
pata += a[3] // 2 * 2
pata += a[4] // 2 * 2
if a[0] % 2 == 1 and a[3] % 2 == 1 and a[4] % 2 == 1:
    pata += 3
pata += a[0] // 2 * 2


patb = 0
if a[0] > 0 and a[3] > 0 and a[4] > 0:
    patb += 3
    a[3] -= 1
    a[4] -= 1
    a[0] -= 1
patb += a[3] // 2 * 2
patb += a[4] // 2 * 2
patb += a[0] // 2 * 2

print(ans + max(pata, patb))

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    x,y = LI()
    if x < 0:
        if y < 0:
            if x < y:
                print(y-x)
            else:
                print(x-y+2)
        else:
            if abs(x) < y:
                print(y-abs(x)+1)
            else:
                print(-y-x+(y>0))
    else:
        if y < 0:
            if x < abs(y):
                print(abs(y)-x+1)
            else:
                print(x+y+1)
        else:
            if x < y:
                print(y-x)
            else:
                print(x-y+(x>0)+(y>0))
    return


def B():

    return


def C():
    a = LI()
    if a[0] > 0 and a[3] > 0 and a[4] > 0:
        print(max(2*(a[0]//2)+a[1]+2*(a[3]//2)+2*(a[4]//2), 2*((a[0]-1)//2)+a[1]+2*((a[3]-1)//2)+2*((a[4]-1)//2)+3))
    else:
        print(2*(a[0]//2)+a[1]+2*(a[3]//2)+2*(a[4]//2))
    return


def D():

    return


def E():

    return


def F():

    return


if __name__ == "__main__":
    C()

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

if a[0] % 2 == 1 and a[3] % 2 == 1 and a[4] % 2 == 1:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2) * 4) // 2
    print(ans + 3)
elif a[0] % 2 == 1 and a[3] % 2 == 1 and a[4] % 2 == 0 and a[4] > 0:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2 - 1) * 4) // 2
    print(ans + 3)
elif a[0] % 2 == 1 and a[3] % 2 == 0 and a[4] % 2 == 1 and a[3] > 0:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2 - 1) * 4 + (a[4] // 2) * 4) // 2
    print(ans + 3)
elif a[0] % 2 == 0 and a[3] % 2 == 1 and a[4] % 2 == 1 and a[0] > 0:
    ans = ((a[0] // 2 - 1) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2) * 4) // 2
    print(ans + 3)
else:
    ans = ((a[0] // 2) * 4 + a[1] * 2 + (a[3] // 2) * 4 + (a[4] // 2) * 4) // 2
    print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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







x = (I//2 + J//2 + L//2) * 2
if I>0 and J>0 and L>0:
    x = max(x,((I-1)//2 + (J-1)//2 + (L-1)//2) * 2 + 3)
x += O

print(x)

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

Solution (Python):
a_i,a_o,a_t,a_j,a_l,a_s,a_z=map(int,input().split())
ans1=a_o
if min(a_i,a_j,a_l)==0:
  ans2=2*(a_i//2+a_j//2+a_l//2)
else:
  ans2=max(2*(a_i//2+a_j//2+a_l//2),3+2*((a_i-1)//2+(a_j-1)//2+(a_l-1)//2))
print(ans1+ans2)

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

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

Solution (Python):
A = {k:a for k,a in zip(list("IOTJLSZ"),map(int,input().split()))}
m = min(A["I"],A["J"],A["L"])
ans = 0
for i in range(min(2,m+1)):
    ans = max(ans, 3*i + A["O"] + (A["I"]-i)//2*2 + (A["J"]-i)//2*2 + (A["L"]-i)//2*2)
print(ans)

Solution (Python):

a_I, a_O, a_T, a_J, a_L, a_S, a_Z = map(int, input().split())


R = ((a_I % 2 + a_J % 2 + a_L % 2) >= 2) and min(a_I, a_J, a_L) >= 1
ans = a_O + 2 * ((a_I - R) // 2) + 2 * ((a_J - R) // 2) + \
    2 * ((a_L - R) // 2) + 3 * R


print(ans)

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

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

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

Solution (Python):
a,square,qqq,b,c,qqqq,qqqqq=  list(map(int,input().split()))

a_ = a%2
b_ = b%2
c_ = c%2

b_sub = b-b_
c_sub = c-c_

if b_==1 and c_==1 and a>0:
    a=a-1
    a_ = a%2
    a_sub = a-a_
    print(a_sub+b_sub+c_sub+3+square)
elif a_==1 and c_==1 and b>0:
    a_sub = a-a_
    b = b-1
    b_ = b%2
    b_sub=b-b_
    print(a_sub+b_sub+c_sub+3+square)
elif a_==1 and b_==1 and c>0:
    a_sub = a-a_
    c = c-1
    c_ = c%2
    c_sub=c-c_
    print(a_sub+b_sub+c_sub+3+square)    
else:
    a_ = a%2
    a_sub = a-a_
    print(a_sub+b_sub+c_sub+square)

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())


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








a.pop(6)
a.pop(5)
a.pop(2)
s = sum(a)
for i in range(4):
    if i != 1 and a[i]%2: s-=1
if s+3==sum(a):s = sum(a)
if s+2==sum(a) and a[0] and a[2] and a[3] > 3:s = sum(a)-1
print(s)

Solution (Python):
i,o,t,j,l,s,z = map(int,input().split())
a = 0
b = 0
if i > 0 and j > 0 and l > 0:
    a += 3
    for k in [i-1,j-1,l-1]:
        if k % 2 == 1:
            a += k-1
        else:
            a += k

for k in [i,j,l]:
        if k % 2 == 1:
            b += k-1
        else:
            b += k
print(o + max(a,b))

Solution (Python):
A=list(map(int,input().split()))
ans=A[1]
I,J,L=A[0],A[3],A[4]
odd_cnt=I%2+J%2+L%2
if odd_cnt==0 or odd_cnt==3:
    ans+=I+J+L
elif odd_cnt==1:
    ans+=I+J+L-1
else:
    if I*J*L:
        ans+=I+J+L-1
    else:
        ans+=I+J+L-2
print(ans)

Solution (Python):


import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    
    A = LI()

    res = 0
    for e in (0, 3, 4):
        res += A[e] // 2 * 2

    if all([A[0], A[3], A[4]]):
        tmp = 3
        for e in (0, 3, 4):
            tmp += (A[e] - 1) // 2 * 2
        if res < tmp:
            res = tmp

    return res + A[1]


print(main())

Solution (Python):
a,b,c,d,e,f,g = map(int,input().split())
res = []
res.append(b + (a//2)*2+ d//2*2 + e//2*2)
if a >= 1 and d >= 1 and e >= 1:
    res.append(3 + b + (a-1)//2*2 + (d-1)//2*2 + (e-1)//2*2)
print(max(res))

Solution (Python):
i, o, t, j, l, s, z = (int(a) for a in input().split())

a = o + i//2*2 + j//2*2 + l//2*2
if i > 0 and j > 0 and l > 0:
    b = 3 + o + (i-1)//2*2 + (j-1)//2*2 + (l-1)//2*2
else:
    b = 0
print(max(a,b))

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

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

ans = o










odd_num = (i % 2) + (j % 2) + (l % 2)
if odd_num >= 2 and i > 0 and j > 0 and l > 0:
    ans += 3
    i -= 1
    j -= 1
    l -= 1
ans += (i // 2) * 2
ans += (j // 2) * 2
ans += (l // 2) * 2
print(ans)

Solution (Python):
I, O, T, J, L, S, Z = map(int, input().split())
res = O
res += sum(map(lambda x: x//2*2, [I, J, L]))
res += 3*min(map(lambda x: x%2, [I, J, L]))

res2 = O
if I and J and L:
    res2 += 3
    I, J, L = map(lambda x: x-1, [I, J, L])

res2 += sum(map(lambda x: x//2*2, [I, J, L]))
print(max(res, res2))

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

Solution (Python):
t=[int(i) for i in input().split()]
if t[0]%2==t[3]%2==t[4]%2:
  print(t[0]+t[1]+t[3]+t[4])
else:
  if (t[0]+t[3]+t[4])%2==0 and t[0]*t[2]*t[4]==0:
    print(t[0]+t[1]+t[3]+t[4]-2)
  else:
    print(t[0]+t[1]+t[3]+t[4]-1)

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

Solution (Python):
def inpl(): return [int(i) for i in input().split()]
i, o, t, j, l, s, z = inpl() 
i, j, l = sorted([i,j,l])
if not (l-i)%2 and not (j-i)%2:
    print(o+i+j+l)
elif i == 0 and j == 1 and l == 1:
    print(o+i+j+l-2)
else:
    print(o+i+j+l-1)

Solution (Python):
a_i, a_o, a_t, a_j, a_l, a_s, a_z = map(int, input().split())

tri_use = min(a_j, a_l, a_i)
p1 = tri_use * 3

j_ex = a_j - tri_use
l_ex = a_l - tri_use
i_ex = a_i - tri_use

p2 = j_ex//2 * 2 + l_ex//2 * 2 + i_ex//2 * 2

extra = j_ex%2 + l_ex%2 + i_ex%2

p3 = 0
if tri_use >= 1:
    if extra == 2:
        p3 = 1
    elif extra == 3:
        p3 = 3
        
print(p1 + p2 + p3 + a_o)

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

x, y, z = sorted([aI, aJ, aL])

ans = aO
if x == 0:
    ans += y//2 * 2 + z//2 * 2
else:
    ans += (x-1) * 3
    y -= x-1
    z -= x-1
    ans += max(3 + (z-1)//2 * 2 + (y-1)//2 * 2, z//2 * 2 + y//2 * 2)

print(ans)

Solution (Python):
Ai, Ao, At, Aj, Al, As, Az = map(int, input().split())

ans = Ao + 2*(Ai//2 + Aj//2 + Al//2)
if Ai>0 and Aj>0 and Al>0:
  ans = max(ans, Ao + 2*((Ai-1)//2 + (Aj-1)//2 + (Al-1)//2) + 3)
  
print(ans)

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

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

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

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

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


aI, aO, aT, aJ, aL, aS, aZ = li()

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

else:
    ans = (aI//2)*2 + (aJ//2)*2 + (aL//2)*2 + aO

print(ans)

Solution (Python):
a = [int(i) for i in input().split()]
f = lambda x: x-x%2
ans = a[1]+f(a[0])+f(a[3])+f(a[4])
if a[0] and a[3] and a[4]: ans = max(ans, a[1]+f(a[0]-1)+f(a[3]-1)+f(a[4]-1)+3)
print(ans)

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

ans1 = 0

if X[0] > 0 and X[3] > 0 and X[4] > 0:
    i, j, l = X[0] - 1, X[3] - 1, X[4] - 1
    ans1 += 6
    ans1 += 4 * (i // 2) + 4 * (j // 2) + 4 * (l // 2)
    ans1 += 2 * X[1]

i, j, l = X[0], X[3], X[4]
ans2 = 4 * (i // 2) + 4 * (j // 2) + 4 * (l // 2) + 2 * X[1]

print(max(ans1, ans2) // 2)

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

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

print(ans)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

I,O,T,J,L,S,Z = inpl()
ans1 = ans2 = O
if I > 0 and J > 0 and L > 0:
	ans1 += 3 + (I-1)//2*2 + (J-1)//2*2 + (L-1)//2*2
ans2 += I//2*2 + J//2*2 + L//2*2
print(max(ans1,ans2))

Solution (Python):
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

def f(*xs):
  return sum(x // 2 * 2 for x in xs)

def solve(I, J, L):
  ans = f(I, J, L)
  if min(I, J, L) >= 1:
    ans = max(ans, 3 + f(I-1, J-1, L-1))
  return ans

I, O, _, J, L, _, _ = reads()
ans = O + solve(I, J, L)
print(ans)

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

Solution (Python):
i,o,t,j,l,s,z=map(int,input().split())
a=(i//2+j//2+l//2)*2
print([a,max(a,((i-1)//2+(j-1)//2+(l-1)//2)*2+3)][not(not(i and j and l))]+o)

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


ans+=o





if i>0 and j>0 and l>0:
  evn=0
  if j%2==0:
    evn+=1
  if l%2==0:
    evn+=1
  if i%2==0:
    evn+=1

  if evn<2:
    ans+=3
    i-=1
    j-=1
    l-=1
    

ans+=(i//2)*2
ans+=(j//2)*2
ans+=(l//2)*2


print(ans)

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

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

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

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

print(ans)

Solution (Python):
a=[int(i) for i in input().split()] 
l=min(a[0],a[3],a[4])
a0=(a[0]-l)//2
a3=(a[3]-l)//2
a4=(a[4]-l)//2

if l>0:
  l1=l-1
else:
  l1=0
a10=(a[0]-l1)//2
a13=(a[3]-l1)//2
a14=(a[4]-l1)//2


print(a[1]+max(l*3+a0*2+a3*2+a4*2, l1*3 + a10*2 + a13*2 + a14*2))

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

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

ans1, ans2 = 2*o, 2*o

ans1+=4*((i//2)+ (j//2)+(l//2))

if i and j and l:
  ans2+=6
  ans2+=4*(((i-1)//2)+ ((j-1)//2)+((l-1)//2))

print(max(ans1,ans2)//2)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


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

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

    print(ans // 2)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def ok(a, i, j, l, o):
    if a > min(i, j, l):
        return 0
    i -= a
    j -= a
    l -= a
    return 6 * a + (i // 2) * 4 + (j // 2) * 4 + (l // 2) * 4 + o * 2


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

    low, high, ans = -1, int(1e14) - 1, 0
    while high - low > 1:
        middle = (low + high) // 2
        if ok(middle, i, j, l, o) > ans:
            ans = ok(middle, i, j, l, o)
            low = middle
        else:
            high = middle

    print(ans // 2)


if __name__ == '__main__':
    main()

Solution (Python):
def solve(A):
    
    res = 0
    I = A[0]
    J = A[3]
    L = A[4]

    O = A[1]
    if (I >= 1 and J >= 1 and L >= 1):
        tmp = 3 + ((I - 1) // 2 + (J - 1) // 2 + (L - 1) // 2) * 2 + O
        res = max(res, tmp)
    tmp = (I // 2 + J // 2 + L // 2) * 2 + O
    res = max(res, tmp)
    print (res)


if __name__ == "__main__":
    A = list(map(int, input().split()))
    solve(A)

Solution (Python):
a, b, c, d, e, f, g = map(int, raw_input().split())
if a > 0 and d > 0 and e > 0:
    ans1 = b + a / 2 * 2 + d / 2 * 2 + e / 2 * 2
    ans2 = b + 3 + (a-1) / 2 * 2 + (d-1) / 2 * 2 + (e-1) / 2 * 2
    print max(ans1, ans2)
else:
    print b + a / 2 * 2 + d / 2 * 2 + e / 2 * 2

Solution (Python):



from functools import reduce

def f(s):
    _res = s[1]
    a = [s[0],s[3],s[4]]
    if reduce(lambda x,y: x + y, list(map(lambda x: x%2,a))) > 1 and a[0] > 0 and a[1] > 0 and a[2] > 0 :
        _res = _res + 3
        a = list(map(lambda x: x - 1,a))
    a = list(map(lambda x: x - x % 2,a))
    _res = _res + a[0] + a[1] + a[2]
    return _res


s = input().split(' ')
print(f(list(map(lambda x:int(x),s))))

Solution (Python):
A = list(map(int, input().split()))
K = 0
K = K+A[1]
if A[0]%2==0 and A[3]%2==0 and A[4]%2==0:
	K = K+A[0]+A[3]+A[4]
elif A[0]%2!=0 and A[3]%2!=0 and A[4]%2!=0:
	K = K+A[0]+A[3]+A[4]
elif A[0]+A[3]+A[4]<=2:
	pass
else:
	K = K+A[0]+A[3]+A[4]-1
print(K)

Solution (Python):
def greedy(J, L, I):
    ans = 0
    ans += (J // 2) * 2
    ans += (L // 2) * 2
    ans += (I // 2) * 2
    return ans


def solve(I, O, T, J, L, S, Z):
    ans = O
    tmp1 = greedy(J, L, I)
    if J * L * I > 0:
        tmp1 = max(tmp1, 3 + greedy(J - 1, L - 1, I - 1))
    ans += tmp1
    return ans


I, O, T, J, L, S, Z = map(int, input().split())
print(solve(I, O, T, J, L, S, Z))

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

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

if aL%2 and aJ%2 and aI > 0:
    print(int((aI-1)/2)*2+aO+int(aJ/2)*2+int(aL/2)*2+3)
elif aI%2 and (aL%2 or aJ%2) and aL > 0 and aJ > 0:
    print(int(aI/2)*2+aO+int((aJ-1)/2)*2+int((aL-1)/2)*2+3)
else:
    print(int(aI/2)*2+aO+int(aJ/2)*2+int(aL/2)*2)

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
elif (i % 2 + j % 2 + l % 2 == 2) and i > 0 and j > 0 and l > 0:
	k += 1
print(k)

Solution (Python):
ai, ao, at, aj, al, as_, az = map(int, input().split())
gattai = min(ai, aj, al)
ans = gattai * 3
ai -= gattai
aj -= gattai
al -= gattai
ans += (ai // 2) * 2 + ao + (aj // 2) * 2 + (al // 2) * 2
if gattai and ((aj & al & 1) or (ai & aj & 1) or (ai & al & 1)):
    ans += 1
print(ans)

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

if aI * aJ * aL == 0:
    K = (aI // 2 + aJ // 2 + aL // 2) * 2 + aO
else:
    K1 = ((aI - 1) // 2 + (aJ - 1) // 2 + (aL - 1) // 2) * 2 + aO + 3
    K2 = (aI // 2 + aJ // 2 + aL // 2) * 2 + aO
    K = max([K1, K2])

print(K)

Solution (Python):
A = [int(i) for i in input().split()]
B = [A[1],A[0],A[3],A[4]]
ans = 0
ans += B[0]
if min(B[1:]) == 0:
	for b in B[1:]:
		ans += b//2*2
elif not sum([i%2 for i in B[1:]])%3:
	ans += sum(B[1:])
else:
	ans += sum(B[1:])-1
print(ans)

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

def aa(a):
    total = a[1]
    i6 = min(a[0],a[3],a[4])
    a[0] -= i6
    a[3] -= i6
    a[4] -= i6
    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]
    if a[0] > 0 and a[3]%2 ==  a[4]%2 == 1:
        a[0] -= 1
        a[3] -= 1
        a[4] -= 1
        total += 3
    total += a[0]//2 * 2
    total += a[3]//2 * 2
    total += a[4]//2 * 2
    return total

def cc(a):
    total = a[1]
    if (a[0]%2 == a[3]%2 == 1 and a[4]>0) or (a[0]%2 == a[4]%2 == 1 and a[3]>0) or(a[4]%2 == a[3]%2 == 1 and a[0]>0):
        total += 3
        a[0] -= 1
        a[3] -= 1
        a[4] -= 1
    total += a[0]//2 * 2
    total += a[3]//2 * 2
    total += a[4]//2 * 2
    if a[0]%2 == a[3]%2 ==  a[4]%2 == 1:
        a[0] -= 1
        a[3] -= 1
        a[4] -= 1
        total += 3
    return total
print(max(aa(a),bb(b), cc(c)))

Solution (Python):


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) and (I * J * L > 0):
    K += 1
print(K)

Solution (Python):



def greedy(J,L,I):
    ans = 0
    ans += (J // 2) * 2
    ans += (L // 2) * 2
    J -= (J // 2) * 2
    L -= (L // 2) * 2
    if J * L * I > 0:
        ans += 3
        I -= 1
    ans += (I // 2) * 2
    return ans

def solve(I,O,T,J,L,S,Z):
    ans = O
    tmp1 = greedy(J,L,I)
    if J * L * I > 0:
        tmp1 = max(tmp1, 3 + greedy(J-1,L-1,I-1))
    ans += tmp1
    return ans
    
I,O,T,J,L,S,Z = map(int,input().split())
print(solve(I,O,T,J,L,S,Z))

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

K = 0


K += a[1] * 1


if a[0] >= 1 and a[3] >= 1 and a[4] >= 1:
	oddn = 0
	for e in [0, 3, 4]:
		if a[e] % 2 == 1:
			oddn += 1

	if oddn >= 2:
		K += 3
		for e in [0, 3, 4]:
			a[e] -= 1

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

print(K)

Solution (Python):
aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())
ans = aO
p = [aI, aJ, aL]
for i in range(3):
    if p[i] >= 2:
        if p[i] % 2 == 0:
            ans += (p[i] - 2) // 2 * 2
            p[i] = 2
        else:
            ans += p[i] // 2 * 2
            p[i] = 1
p.sort()
if sum(p) >= 5:
    ans += sum(p) // 2 * 2
elif sum(p) == 4:
    if p == [1, 1, 2]:
        ans += 3
    elif p == [0, 2, 2]:
        ans += 4
    else:
        assert(False)
elif sum(p) == 3:
    if p == [0, 1, 2]:
        ans += 2
    elif p == [1, 1, 1]:
        ans += 3
    else:
        assert(False)
elif sum(p) == 2:
    if p == [0, 0, 2]:
        ans += 2
    elif p == [0, 1, 1]:
        pass
    else:
        assert(False)
else:
    assert(sum(p) <= 1)
print(ans)

Solution (Python):



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 = 0

triples = min([ai, aj, al])
for t in range(max(0, triples-1), triples+1):
    here = ao + 3*t
    here += (2*((ai - t) // 2)
          +2*((aj - t) // 2)
          +2*((al - t) // 2))
    rr = max(rr, here)

print rr

Solution (Python):
i, o, t, j, l, s, z = map(int, raw_input().split())
def f(x, y, z):
    if x >= 0 and y >= 0 and z >= 0 and x % 2 == y % 2 == z % 2:
        return x + y + z
    else:
        return 0
print o + max(f(i, j, l), f(i - 1, j, l), f(i, j - 1, l), f(i, j, l - 1), f(i - 1, j - 1, l), f(i - 1, j, l - 1), f(i, j - 1, l - 1))

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

Solution (Python):
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]:
            rr += (a[i]+1) // 2 * 2
        if rr > r:
            r = rr
    return a[1] + r


print(main())