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:
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)
    if six > 0:
        if I % 2 == 1:
            if J % 2 == 1 and L % 2 == 1: Ans += 6
            elif J % 2 == 1 or L % 2 == 1: Ans += 2
    print(Ans // 2)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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)
    if six > 0:
        if I % 2 == 1:
            if J % 2 == 1 or L % 2 == 1: Ans += 2
    print(Ans // 2)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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
    six = min([I, J, L])
    Ans += six * 3
    I -= six
    J -= six
    L -= six
    Ans += I + J + L
    if six > 0:
        if I % 2 == 1:
            if J % 2 == 1 or L % 2 == 1: Ans += 2
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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
    six = min([I, J, L])
    Ans += six
    I -= six
    J -= six
    L -= six
    Ans += I + J + L
    if six > 0:
        if I % 2 == 1:
            if J % 2 == 1 or L % 2 == 1: Ans += 2
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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+k*3+(i-k)//2*2+(j-k)//2*2+(l-k)//2*2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i,o,t,j,l,s,z=map(int, input().split())
ans=o+j//2*2+l//2*2+i//2*2
if i&1 and j&1 and l&1:
    ans+=1
print(ans)

Submission status: Wrong Answer

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]) // 2
    length += 12 * comb
    i -= comb
    j -= comb
    l -= comb
    length += 4 * ((i // 2) + (j // 2) + (l // 2))
    if i % 2 == j % 2 == l % 2 == 1: length += 6
    print(length // 2)
   
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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: length += 2
    elif lem == 3: length += 6
    print(length // 2)
   
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    i, o, t, j, l, s, z = map(int, input().split())
    length = o * 2
    #長方形>> i2個:legth += 4; 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))
    print(length // 2)
   
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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 + 3
ans2 = o + (i//2)*2 + (j//2)*2 + (l//2)*2
ans = max(ans1,ans2)
print(ans)

Submission status: Wrong Answer

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

print(a//2*2 + (1 if 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)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
i,o,t,j,l,s,z = map(int,input().split())
ans = o + (i//2)*2 + (j//2)*2 + (l//2)*2
i -= (i//2)*2
j -= (j//2)*2
l -= (l//2)*2
ans += 3*min(i,j,l)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
i,o,t,j,l,s,z = map(int,input().split())
ans = o + 3*min(i,j,l)
i -= min(i,j,l)
j -= min(i,j,l)
l -= min(i,j,l)
ans += (i//2)*2 + (j//2)*2 + (l//2)*2
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(a//2*2+b+c//2*2+d//2*2)

Submission status: Wrong Answer

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

ans = 0

ans += 2 * (A[0] // 2)
ans += A[1]
ans += 2 * (A[3] // 2)
ans += 2 * (A[4] // 2)

print(ans)

Submission status: Wrong Answer

Solution code:
i,o,t,j,l,s,z=map(int,input().split())
res=0
if 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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i,o,t,j,l,s,z=map(int,input().split())
res=0
res+=(i//2)*2
res+=o
res+=(j//2)*2
res+=(l//2)*2
print(res)

Submission status: Wrong Answer

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
res = max(res, m * 3 + ((I - m) // 2) * 2 + ((J - m) // 2) * 2 + ((L - m) // 2) * 2 + O)
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
I, O, _, J, L, _, _ = map(int, input().split())
res = (I // 2) * 2 + O + (J // 2) * 2 + (L // 2) * 2 + ((I % 2) * (J % 2) * (L % 2)) * 3
res = max(res, min(I, J, L) * 3 + ((I - min(I, J, L)) // 2) * 2 + ((J - min(I, J, L)) // 2) * 2 + ((L - min(I, J, L)) // 2) * 2)
print(res)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
I, O, T, J, L, S, Z = map(int, input().split())
a = I * 2 + O * 2 + T + J * 2 + L * 2 + S * 2 + Z * 2
b = I * 2 + O * 2 + T * 3 + J * 2 + L * 2 + S * 2 + Z * 2
print((a - (b - a) // 2) // 2)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
I, O, _, J, L, _, _ = map(int, input().split())
print((I // 2) * 2 + O + (J // 2) * 2 + (L // 2) * 2 + ((I % 2) * (J % 2) * (L % 2)) * 3)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
I, O, _, J, L, _, _ = map(int, input().split())
print((I // 2) * 2 + O + (J // 2) * 2 + (L // 2) * 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i, o, t, j, l, s, z = map(int, input().split())
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: Wrong Answer

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

Submission status: Wrong Answer

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%2 & b%2 & c%2:
  ans+=3
print(ans)

Submission status: Wrong Answer

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%2 & b%2 & c%2:
  ans+=1
print(ans)

Submission status: Wrong Answer

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 == 0 and A[3] != 0:
  S += 1
elif A[3] % 2 == 1 and A[4] % 2 == 0 and A[0] % 2 == 0 and A[4] != 0:
  S += 1
print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
    if I%2 and J%2 and L%2:
        res += 3
    return res

def check2(I, J, L):
    cnt = min(I, J, L)
    I -= cnt
    J -= cnt
    L -= cnt
    res = cnt * 3
    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: Wrong Answer

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

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

ans = 0
ans += I - I%2
ans += O
ans += J - J%2
ans += L - L%2

if I%2 and J%2 and L%2:
    ans += 3

print(ans)

Submission status: Wrong Answer

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

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

ans = 0
ans += I - I%2
ans += O
ans += J - J%2
ans += L - L%2
print(ans)

Submission status: Wrong Answer

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
ans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]
print(ans)

Submission status: Wrong Answer

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*=6
ans+=(a[0]//2*4)+(a[3]//2*4)+(a[4]//2*4)+a[1]*2
print(ans)

Submission status: Wrong Answer

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)
    B = 3+2*((a_I-1)//2) + 2*((a_J-1)//2) + 2*((a_L-1)//2)
    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: Wrong Answer

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型の使い方はふた通り
    ans += 2*(a_I//2)
    ans += 2*(a_J//2)
    ans += 2*(a_L//2)
    if a_I % 2 == 1 and a_J % 2 == 1 and a_L % 2 == 1:
        ans += 3

    # T, S, Z
    # T, S, Zは使うことができない
    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: Wrong Answer

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型は、自身を二つ組み合わせることでしか使えない
    ans += 2*(a_I//2)
    ans += 2*(a_J//2)
    ans += 2*(a_L//2)

    # T, S, Z
    # T, S, Zは使うことができない
    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: Wrong Answer

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*2

    # I, J, L型は、自身を二つ組み合わせることでしか使えない
    ans += 4*(a_I//2)
    ans += 4*(a_J//2)
    ans += 4*(a_L//2)

    # T, S, Z
    # T, S, Zは使うことができない
    print(ans//2)

    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: Wrong Answer

Solution code:

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

ans = ao

if ai * aj * al == 0 or (ai%2+aj%2+al%2) in [0,3]:
    ans += ai+aj+al

else:
    ans += ai+aj+al-1

print (ans)

Submission status: Wrong Answer

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==1:
  print(I+O+J+L)
else:
  print(I//2*2+O+J//2*2+L//2*2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
I,O,R,J,L,S,Z=map(int,input().split())
ans=O
j,J=J//2,J%2
l,L=L//2,L%2
i,I=I//2,I%2
ans+=(j+l+i)*2
ans+=min(J,L,I)*3
print(ans)

Submission status: Wrong Answer

Solution code:
I,O,R,J,L,S,Z=map(int,input().split())
ans=O
m=min(I,J,L)
I-=m
J-=m
L-=m
ans+=m*3
ans+=I//2*2
ans+=J//2*2
ans+=L//2*2
print(ans)

Submission status: Wrong Answer

Solution code:
I,O,R,J,L,S,Z=map(int,input().split())
ans=O
m=min(J,L)
n=min(I,m)
J-=m
L-=m
I-=n
m-=n
ans+=3*n
ans+=m*2
ans+=I//2*2
ans+=J//2*2
ans+=L//2*2
print(ans)

Submission status: Wrong Answer

Solution code:
I,O,R,J,L,S,Z=map(int,input().split())
ans=O
m=min(J,L)
n=min(I,m)
I-=n
m-=n
ans+=3*n
ans+=m*2
ans+=I//2*2
print(ans)

Submission status: Wrong Answer

Solution code:
I,O,R,J,L,S,Z=map(int,input().split())
ans=O
m=min(J,L)
n=min(I,m)
I-=n
m-=n
ans+=3*n
ans+=m
ans+=I//2*2
print(ans)

Submission status: Wrong Answer

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:
        ans += max(0,(Ai%2 + Aj%2 + Al%2 -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: Wrong Answer

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

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

Submission status: Wrong Answer

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

ri = d['I'] % 2
rj = d['J'] % 2
rl = d['L'] % 2

ret = d['O'] + (d['I'] - ri) + (d['J'] - rj) + (d['L'] - rl) + (3 if ri * rj * rl else 0)
print(ret)

Submission status: Wrong Answer

Solution code:
i, o, t, j, l, s, z = map(int, input().split())
print(i // 2 * 2 + o + min(j, l) * 2)

Submission status: Wrong Answer

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) >= 2:
        m = 1
        ans = m*3+o
        i -= m
        j -= m
        l -= m
        ans += 2*(i//2+j//2+l//2)
    else:
        ans = 2*(i//2+j//2+l//2)+o
    print(ans)


main()

Submission status: Wrong Answer

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:
        ans = i+j+l+o-1
    print(ans)


main()

Submission status: Wrong Answer

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) >= 2:
        m = min(i, j, l)
        ans = m*3+o
        i -= m
        j -= m
        l -= m
        ans += 2*(i//2+j//2+l//2)
    else:
        ans = 2*(i//2+j//2+l//2)+o
    print(ans)


main()

Submission status: Wrong Answer

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) >= 2:
        ans = min(i, j, l)*3+o
        i -= min(i, j, l)
        j -= min(i, j, l)
        l -= min(i, j, l)
        ans += 2*(i//2+j//2+l//2)
    else:
        ans = 2*(i//2+j//2+l//2)+o
    print(ans)


main()

Submission status: Wrong Answer

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) >= 2:
        ans = min(i, j, l)*3+o
        i -= ans
        j -= ans
        l -= ans
        ans += 2*(i//2+j//2+l//2)
    else:
        ans = 2*(i//2+j//2+l//2)+o
    print(ans)


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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%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: Wrong Answer

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=0
    ans+=aO*2
    ans+=(aI//2)*4
    ans+=(aJ//2)*4
    ans+=(aL//2)*4
    if(aI&1 and aJ&1 and aL&1):
        ans+=6

    print(ans//2)
resolve()

Submission status: Wrong Answer

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 = ans + (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
    ans += 3*min(i % 2, min(j % 2, l % 2))
    
    ans2 = o
    k = min(i, min(l, j))
    i -= k
    l -= k
    j -= k
    ans2 += k * 3
    ans2 += (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
    ans = max(ans ,ans2)
    
 
    print(ans)
 
 
 
    
 
 
    
 
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
    ans2 += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    ans = max(ans, ans2)

    # ans3 = o
    # ans3 += (i // 2) * 2
    
    
    # left = 0
    # right = min(i, min(l, j))
    # for i in range(100):
    #     mi = (left + right) // 2
    #     tans = 3*m
    #     tans += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    #     if ans > tans 

    print(ans)



    


    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
    ans2 += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    ans = max(ans, ans2)

    # ans3 = o
    # ans3 += (i // 2) * 2
    
    
    # left = 0
    # right = min(i, min(l, j))
    # for i in range(100):
    #     mi = (left + right) // 2
    #     tans = 3*m
    #     tans += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    #     if ans > tans 

    print(ans)



    


    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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))
    ans2 += mi * 3
    #ans2 += (i // 2) * 2 + (j // 2) * 2 + (l // 2) * 2
    ans2 += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    ans = max(ans, ans2)

    # ans3 = o
    # ans3 += (i // 2) * 2
    
    
    # left = 0
    # right = min(i, min(l, j))
    # for i in range(100):
    #     mi = (left + right) // 2
    #     tans = 3*m
    #     tans += ((i - mi) // 2) * 2 + ((j - mi) // 2) * 2 + ((l - mi) // 2) * 2

    #     if ans > tans 

    print(ans)



    


    


if __name__ == '__main__':
    main()