Submit solution

Points:
3 (partial)

Time limit:
2.0s

Memory limit:
256M

Author:

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You have 3 sequences , , and , each containing 3 integers. A subsequence of is *valid* if for each in the subsequence, (indices are taken mod 3, so ).

What is the maximum sum of a valid subsequence of ?

#### Input Format

The first row contains , the second row contains , and the third row contains .

for all .

#### Output Format

Output the maximum sum of a valid subsequence of (The subsequence can be empty, in which case the sum would be 0).

#### Sample Input

```
5 6 5
6 5 6
6 1 4
```

#### Sample Output

`5`

#### Explanation for Sample Output

Since and , and are valid and can be included in the subsequence. However, , so cannot be included in the subsequence. This subsequence has sum 5.

## Comments