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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)

Submission status: Accepted

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

Submission status: Accepted

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

    # O型は独立して考えて良い
    ans = a_O

    # I, J, L型の使い方はふた通り
    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))  # type: int
    a_O = int(next(tokens))  # type: int
    a_T = int(next(tokens))  # type: int
    a_J = int(next(tokens))  # type: int
    a_L = int(next(tokens))  # type: int
    a_S = int(next(tokens))  # type: int
    a_Z = int(next(tokens))  # type: int
    solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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
#        print(now1,now2)
        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()

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

del T,S,Z

x = O
# (II), (JIL), (JJ), (LL)
# (JIIJ), (JIIIL) などは使わないとしてよい
# (JIL) は高々1回としてよい

# (JIL) なし
y = ((J//2) + (I//2) + (L//2)) * 2
# (JIL) 1回
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)

Submission status: Accepted

Solution code:
*A, = map(int, input().split())
# IOTJLSZ
d = {c: A[i] for i, c in enumerate('IOTJLSZ')}


# TSZは端を処理できない
# 2K->K
# O:2->1
# II:4->2
# IJL:6->3
# JJ:4->2
# LL:4->2

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd
# from datetime import date, timedelta
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
# input = sys.stdin.readline


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
    #ans += 3*min(i % 2, min(j % 2, l % 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()

Submission status: Accepted

Solution code:
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
# MOD = 998244353

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

ans += O
# I, J, L は 3 つで 1 セット作れる
# 同じの 2 個でも 1 セット作れる
# 貪欲に 3 つのやつつくって、無駄があれば 2 つのほうに移す
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:
        # あまりが 2 個出るなら同じので作ってもらったほうがいい
        s -= 1
        I += 1
        J += 1
        L += 1
    ans += s * 3
ans += (I // 2 + J // 2 + L // 2) * 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

# a2をすべて使用して2*2をたくさん作る
ans += a2 * 2
a2 = 0

#(偶奇奇)のときはa1, a3, a4を1つずつ組み合わせておく
#すると(偶偶奇)となる
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

#(偶偶偶), (偶偶奇), (奇奇奇)のとき
# a1を使用して2*4をたくさん作る
ans += (a1 // 2) * 4
a1 = a1 % 2
# a3を使用して2*4をたくさん作る
ans += (a3 // 2) * 4
a3 = a3 % 2
# a4を使用して2*4をたくさん作る
ans += (a4 // 2) * 4
a4 = a4 % 2
# もしa1, a3, a4が1つずつ余っているなら2*6を1つ作れる
if a1 == 1 and a3 == 1 and a4 == 1:
    ans += 6

print(ans // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a = [int(item) for item in input().split()]
ans = a[1]

# Make 2 group at first 
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

# Make 3 group at first 
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))

Submission status: Accepted

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

#A
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

#B
def B():

    return

#C
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

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Accepted

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

Submission status: Accepted

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

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

# T,S,Z は無関係
# I,O,J,Lに注目
# Oは足すだけ
# I,J,Lが問題
# II, JIL, JJ, LL

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力
a_I, a_O, a_T, a_J, a_L, a_S, a_Z = map(int, input().split())

# 使用するテトロミノはI, O, J, L型のみ
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())
#n = ip()                                     #入力整数1つ
#a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8

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():
    # ai, ao, at, aj, al, as, az
    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())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

# a: xoooo.
#    xxx...
# b: xooo
#    xxxo
# c: xxxo
#    xooo
# d: oooo
#    xxxx

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans1 = 0
# IJL
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)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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