E - Stolen Table

Languages: C, C++, Java, Python, Kotlin
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
3 3 2 2 3 2 3 3
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
89
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
1 1 1 2
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
0
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
5 5 2 2 3 3 3 2 2 2 3 3
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
49049891
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
12 13 2 2 2 3 3 4 4 4 4 5 5 5 2 3 3 3 3 4 5 5 5 5 5 5 5
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
808346164
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
2 3 2 3 3 1 5
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
0
--- Showing first 30 lines (click "Copy" to get full content) ---